Using .Value fails when initialising a user form
Hi All,
I have a problem using .Value to determine the value in a list box. To demonstrate i setup a simple userform with ListBox1 and ListBox2. I then added the following code to the userform:
Code:
Private Sub UserForm_Initialize()
ListBox1.AddItem "bob"
ListBox1.AddItem "bill"
ListBox1.ListIndex = 1
Box1Val = ListBox1.Value
ListBox2.AddItem "Frank"
ListBox2.AddItem "Harry"
ListBox2.ListIndex = 1
Box2Val = ListBox2.Value
End Sub
Running this i get
Box1Val = "Bill" (expected as ListIndex = 1)
Box2Val = "" (Why am i not getting "Harry"???)
If i replace ListBox2.Value with ListBox2.List(1) i get the correct value - but i want to know why .Value is working in one instance and not another and how to fix this.
Thanks for any help
Matt