Transfer Variable from Form to Module

G

Guest

I am having problems transferring a variable from a form back to a module.
My module is:

Public invP, vP
Sub Mod()
..
..
UserForm6.Show
MsgBox invP & vP
..
end sub

Private Sub CommandButton1_Click()
..
invP = ListBox1.ListIndex + 1
vP = ListBox2.ListIndex + 1
..
end sub

In the routine CommandButton1 invP=1 and vP=3
when the control returns to the routine Mod they both equal zero.
Any ideas why and how to make them behave?
 
G

Guest

I imagine you have already checked this, but is anything in the listbox? If
so, has anything been selected before clicking the button?
 
G

Guest

Thank you for the ideas - code for cancel button had been duplicated in code
for OK button - so code was setting to zero!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top