change value of label (1 Viewer)

hardik_088

Registered User.
Local time
Today, 15:26
Joined
May 31, 2011
Messages
82
hi friends,
I have button and i want that if i clicked on button value should change
for example
i have label and caption is "Mother" i want if i click on button then label caption should change from Mother to Father and if i click again it should change from father to Grandfather so what can i do?
 

thesavo

Registered User.
Local time
Today, 18:26
Joined
Jun 23, 2011
Messages
10
So you have a predefined pattern you want this label to change.


Mother <CLICK> Father <CLICK> Grandfather

  • What if I click the button again after Grandfather?
  • Do you want this label to be retained after closing the form?
  • Do you want this label to be retained after closing the database?
 

hardik_088

Registered User.
Local time
Today, 15:26
Joined
May 31, 2011
Messages
82
thanks for reply
yes if i close form and open again mother should be there.
 

thesavo

Registered User.
Local time
Today, 18:26
Joined
Jun 23, 2011
Messages
10
Ok, so you want to default it to "Mother".
What if I click it after the label reads "grandfather" ?
 

hardik_088

Registered User.
Local time
Today, 15:26
Joined
May 31, 2011
Messages
82
if there is value grandfather on label and if you cliked button nothing should happen.

thanks
 

VilaRestal

';drop database master;--
Local time
Today, 23:26
Joined
Jun 8, 2011
Messages
1,046
It seems odd that Grandmothers should be left out but heh...
The code would be something like:

If Label.Caption = "Mother" Then
Label.Caption = "Father"
ElseIf Label.Caption = "Father" Then
Label.Caption = "Grandfather"
End If
 

missinglinq

AWF VIP
Local time
Today, 18:26
Joined
Jun 20, 2003
Messages
6,423
This will change the Caption on the button itself each time it is clicked. You just set the Default value you want in the Button's Properties Box in Design View.
Code:
Private Sub ParentsButton_Click()
If ParentsButton.Caption = "Mother" Then
    ParentsButton.Caption = "Father"
Else
   ParentsButton.Caption = "Mother"
End if
End Sub
To Change an independent Label, as you're talking about, you'd just modify it to
Code:
Private Sub ChangeButton_Click()
If ParentLabel.Caption = "Mother" Then
    ParentLabel.Caption = "Father"
Else
   ParentLabel.Caption = "Mother"
End if
End Sub
Linq ;0)>
 

Users who are viewing this thread

Top Bottom