Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a Class oMenu that I have defined in a sub called cmdBox1_Click

 

I have another event called cmdBox2_Click tha I want to access the properties, etc from the object defined in cmdBox1_Click.

 

Any way to do this?

 

Example:

 

Sub cmdBox1_Click

 

Dim oMenu as New oClassMenu

 

'Set the property here...

oMenu.MenuSelection = "Edit"

 

End Sub

 

Sub cmdBox2_Click

 

'Want to access the property MenuSelection set from cmdBox1_ Click sub

 

msgbox( oMenu.MenuSelection)

 

End Sub

  • Leaders
Posted
Can't you declare your oMenu outside of your form's procedures so that all of the subs can access it?

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • *Experts*
Posted

Your best bet is to define oMenu at the form level instead of inside the cmdBox1_Click event. Then it's accessible anywhere on the form. From within cmdBox2_Click, you can first check if it's been set with something like:

If Not (oMenu Is Nothing) Then
   ' Use oMenu
End If

 

At least, that's how you'd check it in VB6 - I think it's the same syntax :)

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...