PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on March 25, 2010, 10:10:02 PM

Title: ListBox - Where am i going wrong?
Post by: Martin Francom on March 25, 2010, 10:10:02 PM
Hello,
   I have not used the listbox much and am having difficulty etracting the listed items.  I must be making some obvious mistake but i haven't been able to spot it.  The following code returns the same item for all ListBox selections.  Here my code, can anyone spot my error?  What am i doing wrong?


       cnt = FF_ListBox_GetCount( HWND_FORMALLERGYCODES_LIST1 ) 
       For a = 0 To cnt
          sel = FF_ListBox_GetItemData (HWND_FORMALLERGYCODES_LIST1, a )
          wk = FF_ListBox_GetText (HWND_FORMALLERGYCODES_LIST1, sel)
          ? "wk=" & wk
           If Len(Trim$(wk)) > 3  Then
             sVal = sVal & _
              Trim$(Mid$(wk,1,8)) & "," & _
              Trim$(Mid$(wk,9, 30)) & "," & _
              Trim$(Mid$(wk,39, 6)) & ",~"
           End If
       Next


The   wk   value stays the same with each run thru the FOR/NEXT loop.  It is always the first value of the ListBox.  The code doesn't move to the next ListBox item.   Any suggestions?
Title: Re: ListBox - Where am i going wrong?
Post by: José Roca on March 25, 2010, 10:23:09 PM
Change:


For a = 0 To cnt
sel = FF_ListBox_GetItemData (HWND_FORMALLERGYCODES_LIST1, a )
wk = FF_ListBox_GetText (HWND_FORMALLERGYCODES_LIST1, sel)


to:


For a = 0 To cnt - 1
wk = FF_ListBox_GetText (HWND_FORMALLERGYCODES_LIST1, a)

Title: Re: ListBox - Where am i going wrong?
Post by: Martin Francom on March 25, 2010, 10:40:59 PM
Jose,  thank you.