nouellette
asked on
Simple VB Argument question...
I have a quick question about writing a routine..
I have a few controls on my form...let's say a few command buttons called command1 command2 and command3. let's say I also have a checkbox1 and optionbutton1.
I then have a label box at the bottom. I simply want my program to display the last control that was clicked or checked. I'm having trouble finding how to take the control as an argument and display the actual control name in the label field. Any help is appreciated.
I have a few controls on my form...let's say a few command buttons called command1 command2 and command3. let's say I also have a checkbox1 and optionbutton1.
I then have a label box at the bottom. I simply want my program to display the last control that was clicked or checked. I'm having trouble finding how to take the control as an argument and display the actual control name in the label field. Any help is appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jacamar...i can definitely do that...but thats getting around what i really need this to do...and thats to actually pass the control's name through to the label box. basically to write a routine that takes a control as an argument and displays it in the label box.
i believe this is what deightons code is doing but im not 100% sure.
i believe this is what deightons code is doing but im not 100% sure.
ASKER
Deighton...works great...how can I also get the control TYPE for the "ActiveControl"? cntX.Name pulls it's name just fine...but what could I use to also pull the actual type...meaning I could says "you selected " & cntX.Name & "Which is of type " &
After Which is of type...I want to be able to pass the control type too...command button, option button, whatever the control object is...I would like to be able to pull that as well.
After Which is of type...I want to be able to pass the control type too...command button, option button, whatever the control object is...I would like to be able to pull that as well.
ASKER
Deighton...works great...how can I also get the control TYPE for the "ActiveControl"? cntX.Name pulls it's name just fine...but what could I use to also pull the actual type...meaning I could says "you selected " & cntX.Name & "Which is of type " &
After Which is of type...I want to be able to pass the control type too...command button, option button, whatever the control object is...I would like to be able to pull that as well.
After Which is of type...I want to be able to pass the control type too...command button, option button, whatever the control object is...I would like to be able to pull that as well.
ASKER
Nevermind...got it...just changed DISPLAY to NotifyControlType and pulled the control type as well as the control name. Thanks!
Private Sub Command1_Click()
Label1.Caption = Command1.Name
End Sub
Private Sub Command2_Click()
Label1.Caption = Command2.Name
End Sub