SelectedLabel and use of Case

roarnold

Active Member
Licensed User
Longtime User
Afternoon,

I saw Klaus' example of SelectedLabel but it is not in a case structure. I have tried it but it does not recognize "End Select" or "End SelectedLabel"


B4X:
Sub menu

Dim lblpelpain As Label
lblpelpain.Initialize("lblpelpain")
SelectedLabel.Initialize("lblpelpain")
SelectedLabel = "lblpelpain"
lblpelpain.Text = "Pelvic Pain: "
lblpelpain.TextSize = 12
Activity.AddView(lblpelpain, 10dip, 50dip, 140dip, 30dip)
        
   
txtpelpain.Initialize("txtpelpain")
txtpelpain.Hint = "Institution"
txtpelpain.TextSize = 12
Activity.AddView(txtpelpain, 150dip, 50dip, 170dip, 30dip) 
      

Dim lblmedist As Label
lblmedist.Initialize("lblmedist")
lblmedist.Text = "Menstrual Disturbance: "
lblmedist.TextSize = 12
Activity.AddView(lblmedist, 10dip, 80dip, 170dip, 30dip) 

txtmendist.Initialize("txtmendist")
txtaddress.Hint = "Address" 
txtmendist.TextSize = 12
Activity.AddView(txtmendist, 150dip, 80dip, 170dip, 30dip)
        
Dim lblpostbleed As Label
lblpostbleed .Initialize("lblpostbleed")
lblpostbleed .Text = "Postmenstural Bleeding: "
lblpostbleed .TextSize = 12
Activity.AddView(lblpostbleed , 10dip, 110dip, 240dip, 30dip) 

End Sub


Sub Label_Click

Dim SelectedLabel As Label
SelectedLabel = Sender
    
     
Case "txtpelpain"
lblcertain.Color = Colors.Black
lblcertain.Text = "√"
Activity.AddView(lblcertain, 150dip, 50dip, 170dip, 30dip)
Return
               
Case "txtmendist"
lblcertain.Color = Colors.Black
lblcertain.Text = "√"
Activity.AddView(lblcertain, 150dip, 80dip, 170dip, 30dip)
Return     
                  
Case "txtpostbleed"
lblcertain.Color = Colors.Black
lblcertain.Text = "√"
Activity.AddView(lblcertain, 150dip, 110dip, 170dip, 30dip) 
Return


End ?

I am attempting to add a checkmark next to what is touched/clicked in the
above mentioned items.

Any ideas?

BTW: it is for a medical app so I apologize for the required label names.

Thanks,
Ron
 

JTmartins

Active Member
Licensed User
Longtime User
Missing

I think you are missing the following

B4X:
Select VariableBeingAnalized ' This is missing

case "whatever"
.
.
.
case "whatever2"
.
.
.
End Select ' this is missing

José
 
Last edited:
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
JT,

Its there but looks a bit different. Its under Sub Label_Click and shows SelectedLabel = Sender.

I may be trying to do something that may not work as I am using this with a case. Case normally sees Select and End Select as opposed to what I have shown.

So we will see if Klaus or Erel and other distinguished individuals have an idea.

Good thought though and thanks for the input.

R
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Could you explain more in detail what exactly you want to do.
With your code snippets I don't understand exactly what you have on the screen and what you want to do.
Instead of using Labels couldn't you use CheckBoxes ?

Best regards.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Hi Klaus,

Here is the complete module and mind you I have fiddled with it but it compiles ok and runs but doesn't fire. You will see buttons for moving back and save. The labels is to layout the item like "Bleeding" or what have you then the Text code under the label is the right side where I want the check to show up. The code in iOS has a checkmark so I am trying to stay pretty much like that. If need be I could use checkboxes. The "√" looks allot better.

B4X:
#Region  Activity Attributes 
   #FullScreen: False
   #IncludeTitle: False
#End Region

'
'Created by Ron Arnold on 02/18/13.
'Copyright (c) 2011 - 2013 __Cyber Storm Technologies Group__. All rights reserved.
'
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim btn18, btn19, btn20, btn21, btn22, btn23, btn24, btn25, btn50, btn51, btn26, Label45, label46, Label47,  btn90, btn91 As Button
   Dim Label3, label4, label5, Label15, Label16, Label17, Label18, Label49, SelectedLabel As Label
   Dim homeicon As Bitmap
   Dim settingsicon As Bitmap
   Dim abouticon As Bitmap
   Dim Aboutscreen As Bitmap
   Dim Home As Bitmap
   Dim level1button As ImageView 
   Dim level1buttonimage As Bitmap
   Dim level2button As ImageView 
   Dim level2buttonimage As Bitmap
   Dim level3button As ImageView
   Dim level3buttonimage As Bitmap
   Dim txtpelpain, txtmendist, txtpostbleed, txtpelinfect, txtsuscongeab, txtinfertil, txtexcbleed, txtprocadj, txtiud, txtsusmalig, txtunicont, txtpelpro As Label
   Dim lblcertain As Label
   Dim Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      Main.hc.Initialize("hc")
      Activity.LoadLayout("addgyn") ' FROM GYN PAGE
   End If
      layit
      mainscrn

   



End Sub

Sub layit
      
        level1buttonimage.Initialize(File.DirAssets, "homeicon.png")
         level1button.Initialize("level1")
        level1button.Bitmap=level1buttonimage
        Activity.AddView(level1button, 100dip, 420dip, 50dip, 40dip)
             
        level2buttonimage.Initialize(File.DirAssets, "settingsicon.png")' 20dip, 420dip, 380dip, 40dip footer numbers
         level2button.Initialize("level2")
        level2button.Bitmap=level2buttonimage
        Activity.AddView(level2button, 160dip, 420dip, 50dip, 40dip)
        
        level3buttonimage.Initialize(File.DirAssets, "abouticon.png")         
        level3button.Initialize("level3")
        level3button.Bitmap=level3buttonimage
        Activity.AddView(level3button, 220dip, 420dip, 50dip, 40dip)
      
End Sub
Sub mainscrn      
      Label3.Initialize("")
      Label3.Text = "OB Reporter Application"      
      Label3.TextColor = Colors.DarkGray
      Label3.TextSize = 14
      Activity.AddView(Label3, 70dip, 0dip, 300dip, 40dip) ' this is  header      
      
      label4.Initialize("")
      label4.Text = "Indications"
      label4.TextColor = Colors.DarkGray
      label4.TextSize = 14
      Activity.AddView(label4, 120dip, 20dip, 300dip, 40dip)
      
      label5.Initialize("")
      label5.Text = "@Cyber Storm Technologies Group 2011 - 2013 Partnership with Medicos Now"
      label5.TextColor = Colors.DarkGray
      label5.TextSize = 8      
      Activity.AddView(label5, 20dip, 450dip, 380dip, 40dip) ' this is footer
                 
        Dim pnl5 As Panel
'      ScrollViewLayer(0).Initialize(0)
        pnl5.Initialize ("pnl5")
'      pnl2 = ScrollViewLayer(2).Panel
'      pnl2.Color = Colors.Transparent
        Activity.AddView(pnl5, 0dip, 0dip, 360dip, 480dip) 
      
      Dim lblpelpain As Label
        lblpelpain.Initialize("lblpelpain")
      lblpelpain.Text = "Pelvic Pain: "
        lblpelpain.TextSize = 12
      lblpelpain.Tag = "lblpelpain"
'      SelectedLabel.Initialize("lblpelpain")
'      SelectedLabel = lblpelpain
        Activity.AddView(lblpelpain, 10dip, 50dip, 140dip, 30dip)
               
      txtpelpain.Initialize("txtpelpain")
'        txtaddress.Hint = "" 
      txtpelpain.TextSize = 12
        Activity.AddView(txtpelpain, 150dip, 50dip, 100dip, 30dip)


        Dim lblmedist As Label
        lblmedist.Initialize("lblmedist")
        lblmedist.Text = "Menstrual Disturbance: "
        lblmedist.TextSize = 12
        Activity.AddView(lblmedist, 10dip, 80dip, 170dip, 30dip) 
      
      txtmendist.Initialize("txtmendist")
'        txtaddress.Hint = "" 
      txtmendist.TextSize = 12
        Activity.AddView(txtmendist, 150dip, 80dip, 100dip, 30dip)

           
      Dim lblpostbleed As Label
      lblpostbleed .Initialize("lblpostbleed")
        lblpostbleed .Text = "Postmenstural Bleeding: "
        lblpostbleed .TextSize = 12
        Activity.AddView(lblpostbleed , 10dip, 110dip, 240dip, 30dip) 

      txtpostbleed.Initialize("txtpostbleed")
'        txtcity.Hint = ""
      txtpostbleed.TextSize = 12
        Activity.AddView(txtpostbleed, 150dip, 110dip, 100dip, 30dip) ' left, top, width, height
    
      Dim lblpelinfect As Label
        lblpelinfect.Initialize("lblpelinfect")
        lblpelinfect.Text = "Pelvic Infection: "
        lblpelinfect.TextSize = 12
        Activity.AddView(lblpelinfect, 10dip, 140dip, 140dip, 30dip)
      
      txtpelinfect.Initialize("txtpelinfect")
 '       txtpelinfect.Hint = ""
      txtpelinfect.TextSize = 12
        Activity.AddView(txtpelinfect, 150dip, 140dip, 100dip, 30dip) 

        
      Dim lblsuscongeab As Label
      lblsuscongeab.Initialize("lblsuscongeab")
        lblsuscongeab.Text = "Suspected congenital abnomalies: "
        lblsuscongeab.TextSize = 12
        Activity.AddView(lblsuscongeab, 10dip, 170dip, 270dip, 30dip) 

      txtsuscongeab.Initialize("txtsuscongeab")
'        txtsuscongeab.Hint = ""
      txtsuscongeab.TextSize = 12
        Activity.AddView(txtsuscongeab, 150dip, 170dip, 100dip, 30dip)


        Dim lblinfertil As Label
      lblinfertil.Initialize("lblinfertil")
        lblinfertil.Text = "Infertility: "
        lblinfertil.TextSize = 12
        Activity.AddView(lblinfertil, 10dip, 200dip, 170dip, 30dip) 

      txtinfertil.Initialize("txtinfertil")
 '       txtinfertil.Hint = ""
      txtinfertil.TextSize = 12
        Activity.AddView(txtinfertil, 150dip, 200dip, 100dip, 30dip)


        Dim lblexcbleed As Label
      lblexcbleed.Initialize("lblexcbleed")
        lblexcbleed.Text = "Excessive Bleeding: "
        lblexcbleed.TextSize = 12
        Activity.AddView(lblexcbleed, 10dip, 230dip, 230dip, 30dip) 
        
      txtexcbleed.Initialize("txtexcbleed")
'        txtexcbleed.Hint = ""
      txtexcbleed.TextSize = 12
        Activity.AddView(txtexcbleed, 150dip, 230dip, 100dip, 30dip)

      
      Dim lbliud As Label 
      lbliud.Initialize("lbliud")
        lbliud.Text = "Localization of intrauterine Device: "
        lblexcbleed.TextSize = 10
        Activity.AddView(lbliud  , 10dip, 260dip, 300dip, 30dip) 
      
      txtiud.Initialize("txtiud")
'        txtiud.Hint = ""
      txtiud.TextSize = 12
        Activity.AddView(txtiud, 150dip, 260dip, 100dip, 30dip)

      
      Dim lblsusmalig As Label
      lblsusmalig.Initialize("lblsusmalig")
        lblsusmalig.Text = "Suspected malinancy: "
        lblsusmalig.TextSize = 12
        Activity.AddView(lblsusmalig, 10dip, 290dip, 200dip, 30dip) 
        
      txtsusmalig.Initialize("txtsusmalig")
'       txtsusmalig.Hint = ""
      txtsusmalig.TextSize = 12
        Activity.AddView(txtsusmalig, 150dip, 290dip, 100dip, 30dip)

      
      Dim lblunicont As Label
      lblunicont.Initialize("lblunicont")
        lblunicont.Text = "Uniary incontinence: "
        lblunicont.TextSize = 12
        Activity.AddView(lblunicont, 10dip, 320dip, 210dip, 30dip) 
      
      txtunicont.Initialize("txtunicont")
'        txtunicont.Hint = ""
      txtunicont.TextSize = 12
        Activity.AddView(txtunicont, 150dip, 320dip, 100dip, 30dip)

      
      Dim lblpelpro As Label
      lblpelpro.Initialize("lblpelpro")
        lblpelpro.Text = "Pelvic organ prolapse: "
        lblpelpro.TextSize = 12
        Activity.AddView(lblpelpro, 10dip, 350dip, 270dip, 30dip) 
      
      txtpelpro.Initialize("txtpelpro")
'        txtpelpro.Hint = ""
      txtpelpro.TextSize = 12
        Activity.AddView(txtpelpro, 150dip, 230dip, 100dip, 30dip)
      
      Dim lblprocadj As Label
      lblprocadj.Initialize("lblprocadj")
        lblprocadj.Text = "Excessive Bleeding: "
        lblprocadj.TextSize = 12
        Activity.AddView(lblprocadj, 10dip, 380dip, 170dip, 30dip) 
      
      txtprocadj.Initialize("txtprocadj")
'        txtprocadj.Hint = ""
      txtprocadj.TextSize = 12
        Activity.AddView(txtprocadj, 150dip, 260dip, 100dip, 30dip)

      
      btn50.Initialize("btn") 
      btn50.Tag = "50"
      Log(btn50.Tag)
        btn50.Text = "Back"
      btn50.TextSize = 10
        Activity.AddView(btn50,0dip, 0dip, 50dip, 30dip)
      
      btn51.Initialize("btn") 
      btn51.Tag = "51"
      Log(btn51.Tag)
        btn51.Text = "Save"
      btn51.TextSize = 10
        Activity.AddView(btn51,270dip, 0dip, 50dip, 30dip)
      
End Sub

Sub Label_Click
   Dim lbl As Label
   lbl = Sender
          
'   Dim SelectedLabel As Label
'    SelectedLabel = Sender      
   
     Select lbl.Tag                   
              Case "lblpelpain"
               lblpelpain.Color = Colors.Black
                  lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 50dip, 100dip, 30dip)
               Return
               
               Case "txtmendist"
                lblcertain.Color = Colors.Black
                  lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 80dip, 100dip, 30dip)
               Return     
                  
              Case "txtpostbleed"
               lblcertain.Color = Colors.Black
                  lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 110dip, 100dip, 30dip) 
               Return
               
            Case "txtpelinfect"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 140dip, 100dip, 30dip)
               Return
               
            Case "txtsuscongeab"
               lblcertain.Color = Colors.Black
                  lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 170dip, 100dip, 30dip)
               Return
               
            Case "txtinfertil"   
               lblcertain.Color = Colors.Black
                  lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 200dip, 100dip, 30dip)
               Return
               
            Case "txtexcbleed"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 230dip, 100dip, 30dip)
               Return         
            
            Case "txtiud"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 260dip, 100dip, 30dip)
               Return
               
            Case "txtsusmalig"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 290dip, 100dip, 30dip)
               Return
               
            Case "txtunicont"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 320dip, 100dip, 30dip)
               Return
               
            Case "txtpelpro"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√"
               Activity.AddView(lblcertain, 150dip, 230dip, 100dip, 30dip)   
               Return
            Case "txtprocadj"
               lblcertain.Color = Colors.Black
               lblcertain.Text = "√" ' should be last
               Activity.AddView(txtprocadj, 150dip, 260dip, 100dip, 30dip)
                   Return
      
      'Case Else
              
       '           Log("Fail")
            
    End Select
End Sub
Sub btn_Click
      Dim Send As Button
      Send = Sender
    
      Log(Send)
        Select Send.Tag
           Case "50"
               
               Log("Back")
            Dim FirstTime As Boolean
            FirstTime = True
            Activity.Loadlayout("addgyn")
            StartActivity(addgyn)            
         
                            
           Case "51"
               Log("Save") 
'            POPUP GOES HERE
         
      End Select
End Sub
Sub level1_Click

   Activity.Finish
   Activity.LoadLayout("3SelectionList")
   Return True    
End Sub

Sub level2_Click

   Activity.Finish
   StartActivity("settings")    
End Sub

Sub level3_Click

   Activity.Finish
   StartActivity("about")    
End Sub      
      

'
'Created by Ron Arnold on 02/18/13.
'Copyright (c) 2011 - 2013 __Cyber Storm Technologies Group__. All rights reserved.
'
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Could you post the project as a zip file (IDE menu Files / Export As Zip)?
It would be much easier to help you, I could test the program.

From what I've seen, you add labels with for example:
lblmedist.Initialize("lblmedist")
but you want to use one event routine Label_Click to handle all events
so you should use for example:
lblmedist.Initialize("Label")

Then you are using, in the Label_Click routine, lbl.Tag but you never set any Tag property when you add the labels.

Best regards.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Hi Klaus,

You are correct but you knew that. I noticed it before I ran an errand. I will attempt it otherwise I will zip it up and let you stab it.

Thank you for the help,
Ron
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Klaus,

Ok, I have it firing by fixing the miscues you mentioned, added the "Label" to all items and the .Tag. Interesting issue is that when it fire and Select processes the lbl.Tag from Sender it has the Dim label text in Sender instead of the .Tag info.

Am I placing the Tag in the Dim label portion or the txt portion of the code. Guess I could try both.

Appreciate the help.

R
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm not sure that I understand what you are explaining.

You should use :
B4X:
Dim lblmedist As Label
lblmedist.Initialize("Label")
lblmedist.Tag = "lblmedist"
lblmedist.Text = "Menstrual Disturbance: "
lblmedist.TextSize = 12
Activity.AddView(lblmedist, 10dip, 80dip, 170dip, 30dip)
And in the Label_Click routine :
B4X:
Sub Label_Click
    Dim lbl As Label
    lbl = Sender
    Select lbl.Tag
    Case "lblmedist"
    .
    .
    End Select
You can use other Tag values, it's up to you to choose the right one.
Using the label name is a good solution because you directly know which label is concerned.

Best regards.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Klaus.

That did it. Its firing and accomplishing what I want. However, when it hits the CASE on the first item I received a Remove() view Parent Child issue. I have been programmatically coding to avoid this which I usually got when using designer.

Do I need to count view and remove or just use RemoveView?

Thanks,
R
 
Upvote 0
Top