This is really freaking me out. Here is a real simple program:
First, I have a form with 3 listboxes, a textbox, and a command button. Then I populate the listboxes with data. Then I click the command button to execute this code:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
In theory, this loops 4 times, each time selecting the next item in each listbox in order, then adds the selected item from listbox1 (and a space) into the textbox.
Didn't work - the textbox was empty. I scratched my head and tried a bunch of stuff, no luck. Then, just for kicks I tried putting the selected item from textbox2 in the textbox:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox2.Value & " "
Next x
End Sub
It worked. listbox2 contained:
name1
name2
name3
name4
and I got:
name1 name2 name3 name4
in the textbox. It worked for listbox 3 as well. So I figured OK, maybe the listbox1 is corrupted. So I deleted listbox1, and then recreated it. Tested the code:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
and it worked! Listbox1 contained:
id1
id2
id3
id4
and I got:
id1 id2 id3 id4
in the textbox. So I figured problem solved. But get this - NOW it was working with listbox1, but listbox2 STOPPED working!!!! If I tried it with listbox2, I was back to getting nothing in the textbox. So I deleted listbox2.... and 3 stopped working... so I deleted 3... and 1 stopped working... and no matter WHAT I do I can't get all three to work at once! Just for kicks, I also tried changing things to:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.Selected(x) = 1
ListBox2.Selected(x) = 1
ListBox3.Selected(x) = 1
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
and the exact same thing would happen... 2 of them would work, 1 would not.
Does anyone have a clue WHAT THE ^%!$#^%$!#^$%! is going on here?!?!?!? I am freaked out trying to get this running...
Thanks
Steve
First, I have a form with 3 listboxes, a textbox, and a command button. Then I populate the listboxes with data. Then I click the command button to execute this code:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
In theory, this loops 4 times, each time selecting the next item in each listbox in order, then adds the selected item from listbox1 (and a space) into the textbox.
Didn't work - the textbox was empty. I scratched my head and tried a bunch of stuff, no luck. Then, just for kicks I tried putting the selected item from textbox2 in the textbox:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox2.Value & " "
Next x
End Sub
It worked. listbox2 contained:
name1
name2
name3
name4
and I got:
name1 name2 name3 name4
in the textbox. It worked for listbox 3 as well. So I figured OK, maybe the listbox1 is corrupted. So I deleted listbox1, and then recreated it. Tested the code:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.ListIndex = x
ListBox2.ListIndex = x
ListBox3.ListIndex = x
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
and it worked! Listbox1 contained:
id1
id2
id3
id4
and I got:
id1 id2 id3 id4
in the textbox. So I figured problem solved. But get this - NOW it was working with listbox1, but listbox2 STOPPED working!!!! If I tried it with listbox2, I was back to getting nothing in the textbox. So I deleted listbox2.... and 3 stopped working... so I deleted 3... and 1 stopped working... and no matter WHAT I do I can't get all three to work at once! Just for kicks, I also tried changing things to:
Private Sub CommandButton4_Click()
For x = 0 To 3
ListBox1.Selected(x) = 1
ListBox2.Selected(x) = 1
ListBox3.Selected(x) = 1
TextBox4.Text = TextBox4.Text & ListBox1.Value & " "
Next x
End Sub
and the exact same thing would happen... 2 of them would work, 1 would not.
Does anyone have a clue WHAT THE ^%!$#^%$!#^$%! is going on here?!?!?!? I am freaked out trying to get this running...
Thanks
Steve