Anyone know the syntax for calling a click on an item in a list box... IE I have 3 names in a listbox, I click on one of em, and I want it to open another form, and pass the info from that list item to the new form.
Printable View
Anyone know the syntax for calling a click on an item in a list box... IE I have 3 names in a listbox, I click on one of em, and I want it to open another form, and pass the info from that list item to the new form.
In form1:
In form2:Code:Dim X As Integer
Private Sub Form_Load()
For X = 0 To 15
List1.AddItem X
Next X
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form2.Info = List1.Text
Form2.Show
End Sub
Hope that helped!Code:Option Explicit
Public Info As String
Private Sub Form_Load()
MsgBox Info
End Sub
Use the click event of the listbox
'
Form2.Show
Form2.Text1.text = Form1.List1.Text
:D Jop :D
A friendly word of advice... you should never use Public varaiables unless there is no other way around things.....and that according to Microsoft
Later:
Wayne
If you right click the listbox, you get a menu box. by selecting "View Code" you will get (at least I get) a new subroutine.
Private Sub boxname_click()
You put your code in here. Whenever anything in boxname is selected (I assume this is a single select, I don't know what happens in multi-select) the mouse click event is fired.
At least, that's the way it ACTS.
Good Luck
DerFarm
HeSaidJoe, I have to use a public variable right? how do I pass the info the variable then?? yeah you're right, I can pass it to a textbox first :) hehe that's better, but doesn't the textbox takes up memory then?
Why don't you use public variables in a standard module, then the form2 will read from the module
Job, you are right...I should wear my glasses..I thought he was posting the information into a textbox.
Being as he has to pass it to something, if it's a control, use the control (textbox or whatever) and if a var then it should be a public var in a module.
My error! Sorry...I guess this is a time for a public var.
Wayne