#92615 - 2003-08-15 02:24 AM
KixForms Question - ListBox Problem
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Hi Everyone
I am going mad trying to get this basic script to work.
Ok here is the problem, I have a Listview and have inserted the following objects: PC1, PC2, PC3.
Now say I want to have a 'Insert Box' that enters data into the Listview, and in this insert box I type PC1.
I want it to check that PC1 is not already in the Listview already.
I have tried a loop on the ListCount and then Additem if Insert.Text is not the same as List($Loop), but it just repeast it self and I get 20 odd additems.
code:
Function sExcludedListAdd_Click()
If $sExcludedInput.Text = "" $= $FORM.MsgBox("Invalid Netbios Name","Error") Else $x = $sExcludedList.ListCount -1 For $Loop = 0 to $x If $sExcludedInput.Text = $sExcludedList.List($Loop) $= $FORM.MsgBox("("+$sExcludedInput.Text") is already in the Excluded List","Error") Else $sExcludedList.AddItem($sExcludedInput.Text) EndIf Next EndIf
EndFunction
I just don't know how to do this. ???
Any Ideas.
Thanks [ 15. August 2003, 12:13: Message edited by: Richard Farthing ]
|
|
Top
|
|
|
|
#92617 - 2003-08-16 12:07 AM
Re: KixForms Question - ListBox Problem
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Sorry I am so dumb, I meant ListBox .
How would I put the contents of a Listbox into an array. ??.
So then I can do something like this:
code:
If AScan($sExcludedList,$sExcludedInput.Text) = 1 $= $FORM.MsgBox("("+$sExcludedInput.Text") is already in the Excluded List","Error") Else $sExcludedList.AddItem($sExcludedInput.Text) EndIf
|
|
Top
|
|
|
|
#92618 - 2003-08-16 12:38 AM
Re: KixForms Question - ListBox Problem
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
for each $item in $listbox.items if $item.text=" "
endif next
|
|
Top
|
|
|
|
#92619 - 2003-08-16 12:51 AM
Re: KixForms Question - ListBox Problem
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
It don't like that, as soon as I do that it just bombs out the script no error.
code:
For Each $Item In $sExcludedList.Items ? $Item.Text Next
|
|
Top
|
|
|
|
#92622 - 2003-08-15 01:13 PM
Re: KixForms Question - ListBox Problem
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Thanks Jochen your bit works like a dream, just the AS part now, does that look right as it is not finding the PC-01 in the array?
code:
Dim $List
For $Loop = 0 to $sExcludedList.ListCount-1 $sExcludedList.ListIndex = $Loop $List = $List + $sExcludedList.Text If $Loop < $sExcludedList.ListCount - 1 $List = $List + "," EndIf Next $xArray = Split($List,",") If AScan($xArray,$sExcludedInput.Text) = 1 ? $sExcludedInput.Text + ' is Present.' Else ? $sExcludedInput.Text + ' is NOT Present.' EndIf
|
|
Top
|
|
|
|
#92624 - 2003-08-15 01:29 PM
Re: KixForms Question - ListBox Problem
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Thank You Everyone all working.
code:
If $sExcludedInput.Text = "" $= $FORM.MsgBox("Invalid Netbios Name","Error") Else Dim $List
For $Loop = 0 to $sExcludedList.ListCount-1 $sExcludedList.ListIndex = $Loop $List = $List + $sExcludedList.Text If $Loop < $sExcludedList.ListCount - 1 $List = $List + "," EndIf Next $xArray = Split($List,",") If NOT AScan($xArray,$sExcludedInput.Text) = "-1" $= $FORM.MsgBox('('+$sExcludedInput.Text+') is already In the Excluded List','Error') Else $sExcludedInput.Text = Ucase($sExcludedInput.Text) $sExcludedList.AddItem($sExcludedInput.Text) EndIf $sExcludedInput.Text = ""
|
|
Top
|
|
|
|
#92631 - 2003-08-15 02:00 PM
Re: KixForms Question - ListBox Problem
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2175 anonymous users online.
|
|
|