ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List box value problem (https://www.excelbanter.com/excel-programming/424465-list-box-value-problem.html)

callbr549

List box value problem
 
I have several list boxes on a user form, with option buttons. For most of
the listboxes I retrieve the selected value like this (for listbox "lbShift"):

Private Sub lbShift_Click()
Shift = lbShift.Value
End Sub

This works well and behaves as I expected. I then added one more listbox and
tried to get the value the same way:

Private Sub lbNumHours_Click()
NumHours = lbNumHours.Value
End Sub

But a value never gets assigned to NumHours. I've compared everything I can
think of between the different list boxes and can't figure out why most of
them work, but the one I added today doesn't. If I edit the Sub I'm using it
in to use "lbNumHours.Value" instead of "NumHours" it works. Why?

Bob Umlas[_3_]

List box value problem
 
Put a breakpoint on the line
NumHours = lbNumHours.Value
and see if it actually gets there. Perhaps the name changed.
What's the declaration of NumHours? Maybe it exists only in that sub because
you didn't Dim it?


"callbr549" wrote in message
...
I have several list boxes on a user form, with option buttons. For most of
the listboxes I retrieve the selected value like this (for listbox
"lbShift"):

Private Sub lbShift_Click()
Shift = lbShift.Value
End Sub

This works well and behaves as I expected. I then added one more listbox
and
tried to get the value the same way:

Private Sub lbNumHours_Click()
NumHours = lbNumHours.Value
End Sub

But a value never gets assigned to NumHours. I've compared everything I
can
think of between the different list boxes and can't figure out why most of
them work, but the one I added today doesn't. If I edit the Sub I'm using
it
in to use "lbNumHours.Value" instead of "NumHours" it works. Why?





All times are GMT +1. The time now is 12:31 AM.

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