byoung Posted January 27, 2003 Posted January 27, 2003 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 Quote
Leaders Iceplug Posted January 27, 2003 Leaders Posted January 27, 2003 Can't you declare your oMenu outside of your form's procedures so that all of the subs can access it? Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
*Experts* Nerseus Posted January 27, 2003 *Experts* Posted January 27, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.