I'm trying to pass the value of the selected ItemData from Listbox1 in Form A to Form B after the doubleclick event. My question is how can i pass the value to form B? Thank you in advance.
You can give the entire reference in form B, e.g. in the double click event in Form A, just put something like
FormB.whateveryouwant = ListBox1.List(someindex)
For this to work, the variable whateveryouwant must be publicly accessible.
You could also use a global variable. You can set
someglobal = ListBox1.List(someindex)
Then you can access someglobal from wherever you need it in Form B.
The best way is as follows:
In the General Declarations of Form B, you can declare a Private variable (eg private m_MyVar as string).
then and a property let procedure
Public Property Let MyVar(byval strData as string)
m_MyVar = strData
End Property
In your double-click event of the listbox, have something like this:
dim objFormB as FormB
Set objFormB = new FormB
Load objFormB
objFormB.MyVar = Listbox1.Text '//or whatever property you want to use
objFormB.Show vbmodal '//or remove the vbmodal if you want
'Get any info out, then clear the form from memory
UnLoad objFormB
Set objFormB = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.