Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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.

0
nouellette
Asked:
nouellette
  • 4
1 Solution
 
JacamarCommented:
Here's  a quick example with 2 command buttons.  It's not very pretty, but it'll do what you want.

Private Sub Command1_Click()
Label1.Caption = Command1.Name
End Sub
Private Sub Command2_Click()
Label1.Caption = Command2.Name
End Sub
0
 
deightonCommented:
Private Sub Command1_Click()
display Me.ActiveControl

End Sub

Private Sub Command2_Click()
display Me.ActiveControl

End Sub

Sub display(cntX As Control)

    Label1.Caption = cntX.Name


End Sub
0
 
nouelletteAuthor Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nouelletteAuthor Commented:
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.
0
 
nouelletteAuthor Commented:
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.
0
 
nouelletteAuthor Commented:
Nevermind...got it...just changed DISPLAY to NotifyControlType and pulled the control type as well as the control name.  Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now