ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   weird listbox behavior (https://www.excelbanter.com/excel-programming/415983-weird-listbox-behavior.html)

bill

weird listbox behavior
 
All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as a
Rowsource. When the form opens they are all populated and display just fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill



JLGWhiz

weird listbox behavior
 
It is odd. I got the same result on the first try, but when I set a
breakpoint to debug the process, it performed properly. Then after I removed
the breakpoint, it still performed properly. Can't get it to duplicate the
anomaly.

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as a
Rowsource. When the form opens they are all populated and display just fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill




JLGWhiz

weird listbox behavior
 
Hold on, I did get it to repeat the anomaly and it is listbox 2 that is
returning the null string. However, it is showing as selected. I looks like
it might be speed related but can't be positive.

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as a
Rowsource. When the form opens they are all populated and display just fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill




JLGWhiz

weird listbox behavior
 
It appears to be sporatic. Sometimes it will return all three and other
times it returns only the 1st and 3rd. It is always listbox2 that returns
the empty string. Odd. Might be worth reporting to Microsoft to see if they
have an answer.

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as a
Rowsource. When the form opens they are all populated and display just fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill




bill

weird listbox behavior
 
yea I saw similar behavior. Actually, depending upon how I reorder things I
can get any one or two of the three listboxes to have "". I have tried
various delays between writing to the ListIndex, but it had no effect.


"JLGWhiz" wrote in message
...
Hold on, I did get it to repeat the anomaly and it is listbox 2 that is
returning the null string. However, it is showing as selected. I looks
like
it might be speed related but can't be positive.

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as
a
Rowsource. When the form opens they are all populated and display just
fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill






JLGWhiz

weird listbox behavior
 
Here is the set up that I used.

Create UserForm1.
Add three ListBox controls to UserForm1.
Put this code behind ListBox1 on form:

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
ListBox3.ListIndex = ListBox1.ListIndex
v1 = ListBox1.Value '(or .Text)
v2 = ListBox2.Value '(or .Text)
v3 = ListBox3.Value '(or .Text)
MsgBox v1 & " " & v2 & " " & v3
End Sub

Set same row source on Sheet1 for all three listboxes.
Put this code in standard module:

Sub UF1()
UserForm1.Show
End Sub

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as a
Rowsource. When the form opens they are all populated and display just fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill




bill

weird listbox behavior
 
My ListBox1_Click() is functionally identical. Here is another twist, in
UserForm_Activate() I do:

ListBox1.ListIndex = 0

This of course triggers ListBox1_Click(). The form shows all three listboxes
with the first item (listindex = 0) selected. However, Listbox1.Text 1 and
ListBox3.Text are empty and Listbox2 is correct. If I then follow that bny
clicking on ListBox1, ListBox1.Text and ListBox2.Text are correct, but
ListBox3.Text is empty.


"JLGWhiz" wrote in message
...
Here is the set up that I used.

Create UserForm1.
Add three ListBox controls to UserForm1.
Put this code behind ListBox1 on form:

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
ListBox3.ListIndex = ListBox1.ListIndex
v1 = ListBox1.Value '(or .Text)
v2 = ListBox2.Value '(or .Text)
v3 = ListBox3.Value '(or .Text)
MsgBox v1 & " " & v2 & " " & v3
End Sub

Set same row source on Sheet1 for all three listboxes.
Put this code in standard module:

Sub UF1()
UserForm1.Show
End Sub

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as
a
Rowsource. When the form opens they are all populated and display just
fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill






JLGWhiz

weird listbox behavior
 
There must be an explanation, but it will take somebody smarter than me to
give it. Like I said, sounds like one for Microsoft. Post it as an anomaly
for public comments and Microsoft will probably pick up on it. Just make a
new posting but click comments instead of question.

"Bill" wrote:

My ListBox1_Click() is functionally identical. Here is another twist, in
UserForm_Activate() I do:

ListBox1.ListIndex = 0

This of course triggers ListBox1_Click(). The form shows all three listboxes
with the first item (listindex = 0) selected. However, Listbox1.Text 1 and
ListBox3.Text are empty and Listbox2 is correct. If I then follow that bny
clicking on ListBox1, ListBox1.Text and ListBox2.Text are correct, but
ListBox3.Text is empty.


"JLGWhiz" wrote in message
...
Here is the set up that I used.

Create UserForm1.
Add three ListBox controls to UserForm1.
Put this code behind ListBox1 on form:

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
ListBox3.ListIndex = ListBox1.ListIndex
v1 = ListBox1.Value '(or .Text)
v2 = ListBox2.Value '(or .Text)
v3 = ListBox3.Value '(or .Text)
MsgBox v1 & " " & v2 & " " & v3
End Sub

Set same row source on Sheet1 for all three listboxes.
Put this code in standard module:

Sub UF1()
UserForm1.Show
End Sub

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as
a
Rowsource. When the form opens they are all populated and display just
fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill







JLGWhiz

weird listbox behavior
 
Sorry about that. Should be click Suggestion for Microsoft instead of
question.

"Bill" wrote:

My ListBox1_Click() is functionally identical. Here is another twist, in
UserForm_Activate() I do:

ListBox1.ListIndex = 0

This of course triggers ListBox1_Click(). The form shows all three listboxes
with the first item (listindex = 0) selected. However, Listbox1.Text 1 and
ListBox3.Text are empty and Listbox2 is correct. If I then follow that bny
clicking on ListBox1, ListBox1.Text and ListBox2.Text are correct, but
ListBox3.Text is empty.


"JLGWhiz" wrote in message
...
Here is the set up that I used.

Create UserForm1.
Add three ListBox controls to UserForm1.
Put this code behind ListBox1 on form:

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
ListBox3.ListIndex = ListBox1.ListIndex
v1 = ListBox1.Value '(or .Text)
v2 = ListBox2.Value '(or .Text)
v3 = ListBox3.Value '(or .Text)
MsgBox v1 & " " & v2 & " " & v3
End Sub

Set same row source on Sheet1 for all three listboxes.
Put this code in standard module:

Sub UF1()
UserForm1.Show
End Sub

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range as
a
Rowsource. When the form opens they are all populated and display just
fine.
I want an item selected in the first listbox to force the same selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill







bill

weird listbox behavior
 
Unfortunately, I am accessing this Newsgroup with Outlook Express. I do not
have anything to click on that you mention. If you do, please feel free to
post it yourself.

Thanks,

Bill


"JLGWhiz" wrote in message
...
Sorry about that. Should be click Suggestion for Microsoft instead of
question.

"Bill" wrote:

My ListBox1_Click() is functionally identical. Here is another twist, in
UserForm_Activate() I do:

ListBox1.ListIndex = 0

This of course triggers ListBox1_Click(). The form shows all three
listboxes
with the first item (listindex = 0) selected. However, Listbox1.Text 1
and
ListBox3.Text are empty and Listbox2 is correct. If I then follow that
bny
clicking on ListBox1, ListBox1.Text and ListBox2.Text are correct, but
ListBox3.Text is empty.


"JLGWhiz" wrote in message
...
Here is the set up that I used.

Create UserForm1.
Add three ListBox controls to UserForm1.
Put this code behind ListBox1 on form:

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
ListBox3.ListIndex = ListBox1.ListIndex
v1 = ListBox1.Value '(or .Text)
v2 = ListBox2.Value '(or .Text)
v3 = ListBox3.Value '(or .Text)
MsgBox v1 & " " & v2 & " " & v3
End Sub

Set same row source on Sheet1 for all three listboxes.
Put this code in standard module:

Sub UF1()
UserForm1.Show
End Sub

"Bill" wrote:

All,

I have done a fair amount of Excel VBA programming, but this is a new
odd
behavior. I have a form with 3 listboxes. All 3 listboxes have a range
as
a
Rowsource. When the form opens they are all populated and display just
fine.
I want an item selected in the first listbox to force the same
selection
(i.e. listindex) in the other 2 listboxes. In the listbox1_Click()
subroutine I put the following code:

listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex

v1 = listbox1.Value (or .Text)
v2 = listbox2.Value (or .Text)
v3 = listbox3.Value (or .Text)

v1 and v2 have the right stuff but v3 = ""

Any ideas?

TIA,

Bill










All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com