Listbox Row Checks (REALbasic network user group Mailinglist archive)
Back to the thread list
Previous thread: Continue While
Next thread: Fast Date Setup
| Listbox Row Checks |
| Date: 01.03.10 00:56 (Sun, 28 Feb 2010 18:56:41 -0500) |
| From: Chip G. |
|
Why doesn't this code work for checking a listbox for whether this item already exists in the first column?
> Dim i As Integer > > If lbDate.ListCount > 0 Then > For i 1 to lbDate.ListCount > If lbDate.Cell(i,0) pr Then > Return True > End If > Next i > End If > Return False This gives me an out-of-bounds exception. lbDate is the listbox. yr is a String. I'm using this to test for the presence. If it's true I drop out, if it's false I continue onward. |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:43 (Sun, 28 Feb 2010 19:43:06 -0500) |
| From: Chip G. |
|
Got it. Thanks for the prompt responses to my questions!
On Feb 28, 2010, at 19:37, Charles Yeomans wrote: > All Listbox methods taking a row parameter are 0-based. |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:37 (Sun, 28 Feb 2010 19:37:08 -0500) |
| From: Charles Yeomans |
|
On Feb 28, 2010, at 7:10 PM, Karen wrote: > > On Feb 28, 2010, at 7:04 PM, Chip G. wrote: > >> nd it works. So the language reference is incorrect (second >> discovery today) in that it says listbox.listcount is 1-based (page >> 395). > > ListCount ***IS*** 1 based... but row and column ARE 0 based. > All Listbox methods taking a row parameter are 0-based. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:27 (Sun, 28 Feb 2010 16:27:22 -0800) |
| From: Terry Ford |
|
On Feb 28, 2010, at 4:10 PM, Karen wrote: > > On Feb 28, 2010, at 7:04 PM, Chip G. wrote: > >> nd it works. So the language reference is incorrect (second >> discovery today) in that it says listbox.listcount is 1-based (page >> 395). > > ListCount ***IS*** 1 based... but row and column ARE 0 based. I find it easier to remember that "Count", in general, includes the first item which is usually "0". So ten rows in a listbox would be 0 to 9. The only time, I am aware of, when the count equals the last item is the Folderitem.Count property. Terry _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:19 (Sun, 28 Feb 2010 19:19:21 -0500) |
| From: Chip G. |
|
That makes absolutely NO sense.
On Feb 28, 2010, at 19:13, Charles Yeomans wrote: > Because the row and column parameters for Cell are offsets -- they start at 0. |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:13 (Sun, 28 Feb 2010 19:13:55 -0500) |
| From: Charles Yeomans |
|
On Feb 28, 2010, at 6:56 PM, Chip G. wrote: > Why doesn't this code work for checking a listbox for whether this > item already exists in the first column? > >> Dim i As Integer >> >> If lbDate.ListCount > 0 Then >> For i u to lbDate.ListCount >> If lbDate.Cell(i,0) r Then >> Return True >> End If >> Next i >> End If >> Return False > > This gives me an out-of-bounds exception. lbDate is the listbox. yr > is a String. I'm using this to test for the presence. If it's true I > drop out, if it's false I continue onward. > Because the row and column parameters for Cell are offsets -- they start at 0. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:10 (Sun, 28 Feb 2010 19:10:54 -0500) |
| From: Karen |
|
On Feb 28, 2010, at 7:04 PM, Chip G. wrote: > nd it works. So the language reference is incorrect (second discovery today) in that it says listbox.listcount is 1-based (page 395). ListCount ***IS*** 1 based... but row and column ARE 0 based. - Karen _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:09 (Sun, 28 Feb 2010 19:09:34 -0500) |
| From: Karen |
|
On Feb 28, 2010, at 6:56 PM, Chip G. wrote: > Why doesn't this code work for checking a listbox for whether this item already exists in the first column? > >> Dim i As Integer >> >> If lbDate.ListCount > 0 Then >> For i - to lbDate.ListCount >> If lbDate.Cell(i,0) or Then >> Return True >> End If >> Next i >> End If >> Return False > > This gives me an out-of-bounds exception. lbDate is the listbox. yr is a String. I'm using this to test for the presence. If it's true I drop out, if it's false I continue onward. Row is zero based. Try this: Dim i, ubList As Integer ubList Date.ListCount -1 For i 1 to ubList If lbDate.Cell(i,0) hr Then Return True Next i Return False _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Listbox Row Checks |
| Date: 01.03.10 01:04 (Sun, 28 Feb 2010 19:04:29 -0500) |
| From: Chip G. |
|
I found something in the archives which suggested this should be 0-based. I changed the code to be:
> Dim i As Integer > > If lbDate.ListCount > 0 Then > For i to lbDate.ListCount-1 > If lbDate.Cell(i,0) er Then > Return True > End If > Next i > End If > Return False And it works. So the language reference is incorrect (second discovery today) in that it says listbox.listcount is 1-based (page 395). Very frustrating when you find these types of errors and try to work through them with only guessing or the list to get you through. On Feb 28, 2010, at 18:56, Chip G. wrote: > Why doesn't this code work for checking a listbox for whether this item already exists in the first column? > >> Dim i As Integer >> >> If lbDate.ListCount > 0 Then >> For i s to lbDate.ListCount >> If lbDate.Cell(i,0) :r Then >> Return True >> End If >> Next i >> End If >> Return False > > This gives me an out-of-bounds exception. lbDate is the listbox. yr is a String. I'm using this to test for the presence. If it's true I drop out, if it's false I continue onward. |
Links
MBS Realbasic Plugins - Pfarrgemeinde St. Arnulf Nickenich