xref: /trunk/main/wizards/source/tools/Listbox.xba (revision 3e02b54d)
1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*3e02b54dSAndrew Rist<!--***********************************************************
4*3e02b54dSAndrew Rist *
5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
6*3e02b54dSAndrew Rist * or more contributor license agreements.  See the NOTICE file
7*3e02b54dSAndrew Rist * distributed with this work for additional information
8*3e02b54dSAndrew Rist * regarding copyright ownership.  The ASF licenses this file
9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the
10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance
11*3e02b54dSAndrew Rist * with the License.  You may obtain a copy of the License at
12*3e02b54dSAndrew Rist *
13*3e02b54dSAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
14*3e02b54dSAndrew Rist *
15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing,
16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an
17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18*3e02b54dSAndrew Rist * KIND, either express or implied.  See the License for the
19*3e02b54dSAndrew Rist * specific language governing permissions and limitations
20*3e02b54dSAndrew Rist * under the License.
21*3e02b54dSAndrew Rist *
22*3e02b54dSAndrew Rist ***********************************************************-->
23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Listbox" script:language="StarBasic">Option Explicit
24cdf0e10cSrcweirDim OriginalList()
25cdf0e10cSrcweirDim oDialogModel as Object
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweirSub MergeList(SourceListBox() as Object, SecondList() as String)
29cdf0e10cSrcweirDim i as Integer
30cdf0e10cSrcweirDim MaxIndex as Integer
31cdf0e10cSrcweir	MaxIndex = Ubound(SecondList())
32cdf0e10cSrcweir	OriginalList() = AddListToList(OriginalList(), SecondList())
33cdf0e10cSrcweir	For i = 0 To MaxIndex
34cdf0e10cSrcweir		SourceListbox = AddSingleItemToListbox(SourceListbox, SecondList(i))
35cdf0e10cSrcweir	Next i
36cdf0e10cSrcweir	Call FormSetMoveRights()
37cdf0e10cSrcweirEnd Sub
38cdf0e10cSrcweir
39cdf0e10cSrcweir
40cdf0e10cSrcweirSub RemoveListItems(SourceListbox as Object, TargetListbox as Object, RemoveList() as String)
41cdf0e10cSrcweirDim i as Integer
42cdf0e10cSrcweirDim s as Integer
43cdf0e10cSrcweirDim MaxIndex as Integer
44cdf0e10cSrcweirDim CopyList()
45cdf0e10cSrcweir	MaxIndex = Ubound(RemoveList())
46cdf0e10cSrcweir	For i = 0 To MaxIndex
47cdf0e10cSrcweir		RemoveListboxItemByName(SourceListbox, RemoveList(i))
48cdf0e10cSrcweir		RemoveListboxItemByName(TargetListbox, RemoveList(i))
49cdf0e10cSrcweir	Next i
50cdf0e10cSrcweir	CopyList() = OriginalList()
51cdf0e10cSrcweir	s = 0
52cdf0e10cSrcweir	MaxIndex = Ubound(CopyList())
53cdf0e10cSrcweir	For i = 0 To MaxIndex
54cdf0e10cSrcweir		If IndexInArray(CopyList(i),RemoveList())= -1 Then
55cdf0e10cSrcweir			OriginalList(s) = CopyList(i)
56cdf0e10cSrcweir			s = s + 1
57cdf0e10cSrcweir		End If
58cdf0e10cSrcweir	Next i
59cdf0e10cSrcweir	ReDim Preserve OriginalList(s-1)
60cdf0e10cSrcweir	Call FormSetMoveRights()
61cdf0e10cSrcweirEnd Sub
62cdf0e10cSrcweir
63cdf0e10cSrcweir
64cdf0e10cSrcweir&apos; Note Boolean Parameter
65cdf0e10cSrcweirSub InitializeListboxProcedures(oModel as Object, SourceListbox as Object, TargetListbox as Object)
66cdf0e10cSrcweirDim EmptyList()
67cdf0e10cSrcweir	Set oDialogModel = oModel
68cdf0e10cSrcweir	OriginalList()= SourceListbox.StringItemList()
69cdf0e10cSrcweir	TargetListbox.StringItemList() = EmptyList()
70cdf0e10cSrcweirEnd Sub
71cdf0e10cSrcweir
72cdf0e10cSrcweir
73cdf0e10cSrcweirSub CopyListboxItems(SourceListbox as Object, TargetListbox As Object)
74cdf0e10cSrcweirDim NullArray()
75cdf0e10cSrcweir	TargetListbox.StringItemList() = OriginalList()
76cdf0e10cSrcweir	SourceListbox.StringItemList() = NullArray()
77cdf0e10cSrcweirEnd Sub
78cdf0e10cSrcweir
79cdf0e10cSrcweir
80cdf0e10cSrcweirSub FormMoveSelected()
81cdf0e10cSrcweir	Call MoveSelectedListBox(oDialogModel.lstFields, oDialogModel.lstSelFields)
82cdf0e10cSrcweir	Call FormSetMoveRights()
83cdf0e10cSrcweir	oDialogModel.lstSelFields.Tag = True
84cdf0e10cSrcweirEnd Sub
85cdf0e10cSrcweir
86cdf0e10cSrcweir
87cdf0e10cSrcweirSub FormMoveAll()
88cdf0e10cSrcweir	Call CopyListboxItems(oDialogModel.lstFields, oDialogModel.lstSelFields)
89cdf0e10cSrcweir	Call FormSetMoveRights()
90cdf0e10cSrcweir	oDialogModel.lstSelFields.Tag = True
91cdf0e10cSrcweirEnd Sub
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweirSub FormRemoveSelected()
95cdf0e10cSrcweir	Call MoveOrderedSelectedListbox(oDialogModel.lstFields, oDialogModel.lstSelFields, False)
96cdf0e10cSrcweir	Call FormSetMoveRights()
97cdf0e10cSrcweir	oDialogModel.lstSelFields.Tag = True
98cdf0e10cSrcweirEnd Sub
99cdf0e10cSrcweir
100cdf0e10cSrcweir
101cdf0e10cSrcweirSub FormRemoveAll()
102cdf0e10cSrcweir	Call MoveOrderedSelectedListbox(oDialogModel.lstFields, oDialogModel.lstSelFields, True)
103cdf0e10cSrcweir	Call FormSetMoveRights()
104cdf0e10cSrcweir	oDialogModel.lstSelFields.Tag = 1
105cdf0e10cSrcweirEnd Sub
106cdf0e10cSrcweir
107cdf0e10cSrcweir
108cdf0e10cSrcweirSub MoveSelectedListBox(SourceListbox as Object, TargetListbox as Object)
109cdf0e10cSrcweirDim MaxCurTarget as Integer
110cdf0e10cSrcweirDim MaxSourceSelected as Integer
111cdf0e10cSrcweirDim n as Integer
112cdf0e10cSrcweirDim m as Integer
113cdf0e10cSrcweirDim CurIndex
114cdf0e10cSrcweirDim iOldTargetSelect as Integer
115cdf0e10cSrcweirDim iOldSourceSelect as Integer
116cdf0e10cSrcweir	MaxCurTarget = Ubound(TargetListbox.StringItemList())
117cdf0e10cSrcweir	MaxSourceSelected = Ubound(SourceListbox.SelectedItems())
118cdf0e10cSrcweir	Dim TargetList(MaxCurTarget+MaxSourceSelected+1)
119cdf0e10cSrcweir	If MaxSourceSelected &gt; -1 Then
120cdf0e10cSrcweir		iOldSourceSelect = SourceListbox.SelectedItems(0)
121cdf0e10cSrcweir		If Ubound(TargetListbox.SelectedItems()) &gt; -1 Then
122cdf0e10cSrcweir			iOldTargetSelect = TargetListbox.SelectedItems(0)
123cdf0e10cSrcweir		Else
124cdf0e10cSrcweir			iOldTargetSelect = -1
125cdf0e10cSrcweir		End If
126cdf0e10cSrcweir		For n = 0 To MaxCurTarget
127cdf0e10cSrcweir			TargetList(n) = TargetListbox.StringItemList(n)
128cdf0e10cSrcweir		Next n
129cdf0e10cSrcweir		For m = 0 To MaxSourceSelected
130cdf0e10cSrcweir			CurIndex = SourceListbox.SelectedItems(m)
131cdf0e10cSrcweir			TargetList(n) = SourceListbox.StringItemList(CurIndex)
132cdf0e10cSrcweir			n = n + 1
133cdf0e10cSrcweir		Next m
134cdf0e10cSrcweir		TargetListBox.StringItemList() = TargetList()
135cdf0e10cSrcweir		SourceListbox.StringItemList() = RemoveSelected (SourceListbox)
136cdf0e10cSrcweir		SetNewSelection(SourceListbox, iOldSourceSelect)
137cdf0e10cSrcweir		SetNewSelection(TargetListbox, iOldTargetSelect)
138cdf0e10cSrcweir	End If
139cdf0e10cSrcweirEnd Sub
140cdf0e10cSrcweir
141cdf0e10cSrcweir
142cdf0e10cSrcweir
143cdf0e10cSrcweirSub MoveOrderedSelectedListbox(lstSource as Object, lstTarget as Object, bMoveAll as Boolean)
144cdf0e10cSrcweirDim NullArray()
145cdf0e10cSrcweirDim MaxSelected as Integer
146cdf0e10cSrcweirDim MaxSourceIndex as Integer
147cdf0e10cSrcweirDim MaxOriginalIndex as Integer
148cdf0e10cSrcweirDim MaxNewIndex as Integer
149cdf0e10cSrcweirDim n as Integer
150cdf0e10cSrcweirDim m as Integer
151cdf0e10cSrcweirDim CurIndex as Integer
152cdf0e10cSrcweirDim SearchString as String
153cdf0e10cSrcweirDim SourceList() as String
154cdf0e10cSrcweirDim iOldTargetSelect as Integer
155cdf0e10cSrcweirDim iOldSourceSelect as Integer
156cdf0e10cSrcweir	If bMoveAll Then
157cdf0e10cSrcweir		lstSource.StringItemList() = OriginalList()
158cdf0e10cSrcweir		lstTarget.StringItemList() = NullArray()
159cdf0e10cSrcweir	Else
160cdf0e10cSrcweir		MaxOriginalIndex = Ubound(OriginalList())
161cdf0e10cSrcweir		MaxSelected = Ubound(lstTarget.SelectedItems())
162cdf0e10cSrcweir		iOldTargetSelect = lstTarget.SelectedItems(0)
163cdf0e10cSrcweir		If Ubound(lstSource.SelectedItems()) &gt; -1 Then
164cdf0e10cSrcweir			iOldSourceSelect = lstSource.SelectedItems(0)
165cdf0e10cSrcweir		End If
166cdf0e10cSrcweir		Dim SelList(MaxSelected)
167cdf0e10cSrcweir		For n = 0 To MaxSelected
168cdf0e10cSrcweir			CurIndex = lstTarget.SelectedItems(n)
169cdf0e10cSrcweir			SelList(n) = lstTarget.StringItemList(CurIndex)
170cdf0e10cSrcweir		Next n
171cdf0e10cSrcweir		SourceList() = lstSource.StringItemList()
172cdf0e10cSrcweir		MaxSourceIndex = Ubound(lstSource.StringItemList())
173cdf0e10cSrcweir		MaxNewIndex = MaxSelected + MaxSourceIndex + 1
174cdf0e10cSrcweir		Dim NewSourceList(MaxNewIndex)
175cdf0e10cSrcweir		m = 0
176cdf0e10cSrcweir		For n = 0 To MaxOriginalIndex
177cdf0e10cSrcweir			SearchString = OriginalList(n)
178cdf0e10cSrcweir			If IndexinArray(SearchString, SelList()) &lt;&gt; -1 Then
179cdf0e10cSrcweir				NewSourceList(m) =  SearchString
180cdf0e10cSrcweir				m = m + 1
181cdf0e10cSrcweir			ElseIf IndexinArray(SearchString, SourceList()) &lt;&gt; -1 Then
182cdf0e10cSrcweir				NewSourceList(m) =  SearchString
183cdf0e10cSrcweir				m = m + 1
184cdf0e10cSrcweir			End If
185cdf0e10cSrcweir		Next n
186cdf0e10cSrcweir		lstSource.StringItemList() = NewSourceList()
187cdf0e10cSrcweir		lstTarget.StringItemList() = RemoveSelected(lstTarget)
188cdf0e10cSrcweir	End If
189cdf0e10cSrcweir	SetNewSelection(lstSource, iOldSourceSelect)
190cdf0e10cSrcweir	SetNewSelection(lstTarget, iOldTargetSelect)
191cdf0e10cSrcweir
192cdf0e10cSrcweirEnd Sub
193cdf0e10cSrcweir
194cdf0e10cSrcweir
195cdf0e10cSrcweirFunction RemoveSelected(oListbox as Object)
196cdf0e10cSrcweirDim MaxIndex as Integer
197cdf0e10cSrcweirDim MaxSelected as Integer
198cdf0e10cSrcweirDim n as Integer
199cdf0e10cSrcweirDim m as Integer
200cdf0e10cSrcweirDim CurIndex as Integer
201cdf0e10cSrcweirDim CurItem as String
202cdf0e10cSrcweirDim ResultArray()
203cdf0e10cSrcweir	MaxIndex = Ubound(oListbox.StringItemList())
204cdf0e10cSrcweir	MaxSelected = Ubound(oListbox.SelectedItems())
205cdf0e10cSrcweir	Dim LocItemList(MaxIndex)
206cdf0e10cSrcweir	LocItemList() = oListbox.StringItemList()
207cdf0e10cSrcweir	If MaxSelected &gt; -1 Then
208cdf0e10cSrcweir		For n = 0 To MaxSelected
209cdf0e10cSrcweir			CurIndex = oListbox.SelectedItems(n)
210cdf0e10cSrcweir			LocItemList(CurIndex) = &quot;&quot;
211cdf0e10cSrcweir		Next n
212cdf0e10cSrcweir		If MaxIndex &gt; 0 Then
213cdf0e10cSrcweir			ReDim ResultArray(MaxIndex - MaxSelected - 1)
214cdf0e10cSrcweir			m = 0
215cdf0e10cSrcweir			For n = 0 To MaxIndex
216cdf0e10cSrcweir				CurItem = LocItemList(n)
217cdf0e10cSrcweir				If CurItem &lt;&gt; &quot;&quot; Then
218cdf0e10cSrcweir					ResultArray(m) = CurItem
219cdf0e10cSrcweir					m = m + 1
220cdf0e10cSrcweir				End If
221cdf0e10cSrcweir			Next n
222cdf0e10cSrcweir		End If
223cdf0e10cSrcweir		RemoveSelected = ResultArray()
224cdf0e10cSrcweir	Else
225cdf0e10cSrcweir		RemoveSelected = oListbox.StringItemList()
226cdf0e10cSrcweir	End If
227cdf0e10cSrcweirEnd Function
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweirSub SetNewSelection(oListBox as Object, iLastSelection as Integer)
231cdf0e10cSrcweirDim MaxIndex as Integer
232cdf0e10cSrcweirDim SelIndex as Integer
233cdf0e10cSrcweirDim SelList(0) as Integer
234cdf0e10cSrcweir	MaxIndex = Ubound(oListBox.StringItemList())
235cdf0e10cSrcweir	If MaxIndex &gt; -1  AND iLastSelection &gt; -1 Then
236cdf0e10cSrcweir		If iLastSelection &gt; MaxIndex Then
237cdf0e10cSrcweir			Selindex = MaxIndex
238cdf0e10cSrcweir		Else
239cdf0e10cSrcweir			SelIndex = iLastSelection
240cdf0e10cSrcweir		End If
241cdf0e10cSrcweir		Sellist(0) = SelIndex
242cdf0e10cSrcweir		oListBox.SelectedItems() = SelList()
243cdf0e10cSrcweir	End If
244cdf0e10cSrcweirEnd Sub
245cdf0e10cSrcweir
246cdf0e10cSrcweir
247cdf0e10cSrcweirSub ToggleListboxControls(oDialogModel as Object, bDoEnable as Boolean)
248cdf0e10cSrcweir	With oDialogModel
249cdf0e10cSrcweir		.lblFields.Enabled = bDoEnable
250cdf0e10cSrcweir		.lblSelFields.Enabled = bDoEnable
251cdf0e10cSrcweir&apos;		.lstTables.Enabled = bDoEnable
252cdf0e10cSrcweir		.lstFields.Enabled = bDoEnable
253cdf0e10cSrcweir		.lstSelFields.Enabled = bDoEnable
254cdf0e10cSrcweir		.cmdRemoveAll.Enabled = bDoEnable
255cdf0e10cSrcweir		.cmdRemoveSelected.Enabled = bDoEnable
256cdf0e10cSrcweir		.cmdMoveAll.Enabled = bDoEnable
257cdf0e10cSrcweir		.cmdMoveSelected.Enabled = bDoEnable
258cdf0e10cSrcweir	End With
259cdf0e10cSrcweir	If bDoEnable Then
260cdf0e10cSrcweir		FormSetMoveRights()
261cdf0e10cSrcweir	End If
262cdf0e10cSrcweirEnd Sub
263cdf0e10cSrcweir
264cdf0e10cSrcweir
265cdf0e10cSrcweir&apos; Enable or disable the buttons used for moving the available
266cdf0e10cSrcweir&apos; fields between the two list boxes.
267cdf0e10cSrcweirSub FormSetMoveRights()
268cdf0e10cSrcweirDim bIsFieldSelected as Boolean
269cdf0e10cSrcweirDim bSelectSelected as Boolean
270cdf0e10cSrcweirDim FieldCount as Integer
271cdf0e10cSrcweirDim SelectCount as Integer
272cdf0e10cSrcweir	bIsFieldSelected = Ubound(oDialogModel.lstFields.SelectedItems()) &lt;&gt; -1
273cdf0e10cSrcweir	FieldCount = Ubound(oDialogModel.lstFields.StringItemList()) + 1
274cdf0e10cSrcweir	bSelectSelected = Ubound(oDialogModel.lstSelFields.SelectedItems()) &gt; -1
275cdf0e10cSrcweir	SelectCount = Ubound(oDialogModel.lstSelFields.StringItemList()) + 1
276cdf0e10cSrcweir	oDialogModel.cmdRemoveAll.Enabled = SelectCount&gt;=1
277cdf0e10cSrcweir	oDialogModel.cmdRemoveSelected.Enabled = bSelectSelected
278cdf0e10cSrcweir	oDialogModel.cmdMoveAll.Enabled = FieldCount &gt;=1
279cdf0e10cSrcweir	oDialogModel.cmdMoveSelected.Enabled = bIsFieldSelected
280cdf0e10cSrcweir	oDialogModel.cmdGoOn.Enabled = SelectCount&gt;=1
281cdf0e10cSrcweir	&apos; This flag is set to &apos;1&apos; when the lstSelFields has been modified
282cdf0e10cSrcweirEnd Sub
283cdf0e10cSrcweir
284cdf0e10cSrcweir
285cdf0e10cSrcweirFunction AddSingleItemToListbox(ByVal oListbox as Object, ListItem as String, Optional iSelIndex) as Object
286cdf0e10cSrcweirDim MaxIndex as Integer
287cdf0e10cSrcweirDim i as Integer
288cdf0e10cSrcweir
289cdf0e10cSrcweir	MaxIndex = Ubound(oListbox.StringItemList())
290cdf0e10cSrcweirDim LocList(MaxIndex + 1)
291cdf0e10cSrcweir&apos; Todo: This goes faster with the Redim LocList(MaxIndex + 1) Preserve function
292cdf0e10cSrcweir	For i = 0 To MaxIndex
293cdf0e10cSrcweir		LocList(i) = oListbox.StringItemList(i)
294cdf0e10cSrcweir	Next i
295cdf0e10cSrcweir	LocList(MaxIndex + 1) = ListItem
296cdf0e10cSrcweir	oListbox.StringItemList() = LocList()
297cdf0e10cSrcweir	If Not IsMissing(iSelIndex) Then
298cdf0e10cSrcweir		SelectListboxItem(oListbox, iSelIndex)
299cdf0e10cSrcweir	End If
300cdf0e10cSrcweir	AddSingleItemToListbox() = oListbox
301cdf0e10cSrcweirEnd Function
302cdf0e10cSrcweir
303cdf0e10cSrcweir
304cdf0e10cSrcweirSub	EmptyListbox(oListbox as Object)
305cdf0e10cSrcweirDim NullList() as String
306cdf0e10cSrcweir	oListbox.StringItemList() = NullList()
307cdf0e10cSrcweirEnd Sub
308cdf0e10cSrcweir
309cdf0e10cSrcweir
310cdf0e10cSrcweirSub	SelectListboxItem(oListbox as Object, iSelIndex as Integer)
311cdf0e10cSrcweirDim LocSelList(0) as Integer
312cdf0e10cSrcweir	If iSelIndex &lt;&gt; -1 Then
313cdf0e10cSrcweir		LocSelList(0) = iSelIndex
314cdf0e10cSrcweir		oListbox.SelectedItems() = LocSelList()
315cdf0e10cSrcweir	End If
316cdf0e10cSrcweirEnd Sub
317cdf0e10cSrcweir
318cdf0e10cSrcweir
319cdf0e10cSrcweirFunction GetSelectedListboxItems(oListbox as Object)
320cdf0e10cSrcweirDim SelList(Ubound(oListBox.SelectedItems())) as String
321cdf0e10cSrcweirDim i as Integer
322cdf0e10cSrcweirDim CurIndex as Integer
323cdf0e10cSrcweir	For i = 0 To Ubound(oListbox.SelectedItems())
324cdf0e10cSrcweir		CurIndex = oListbox.SelectedItems(i)
325cdf0e10cSrcweir		SelList(i) = oListbox.StringItemList(CurIndex)
326cdf0e10cSrcweir	Next i
327cdf0e10cSrcweir	GetSelectedListboxItems() = SelList()
328cdf0e10cSrcweirEnd Function
329cdf0e10cSrcweir
330cdf0e10cSrcweir
331cdf0e10cSrcweir&apos; Note: When using this Sub it must be ensured that the
332cdf0e10cSrcweir&apos; &apos;RemoveItem&apos; appears only only once in the Listbox
333cdf0e10cSrcweirSub RemoveListboxItemByName(oListbox as Object, RemoveItem as String)
334cdf0e10cSrcweirDim OldList() as String
335cdf0e10cSrcweirDim NullList() as String
336cdf0e10cSrcweirDim i as Integer
337cdf0e10cSrcweirDim a as Integer
338cdf0e10cSrcweirDim MaxIndex as Integer
339cdf0e10cSrcweir	OldList = oListbox.StringItemList()
340cdf0e10cSrcweir	MaxIndex = Ubound(OldList())
341cdf0e10cSrcweir	If IndexInArray(RemoveItem, OldList()) &lt;&gt; -1 Then
342cdf0e10cSrcweir		If MaxIndex &gt; 0 Then
343cdf0e10cSrcweir			a = 0
344cdf0e10cSrcweir			Dim NewList(MaxIndex -1)
345cdf0e10cSrcweir			For i = 0 To MaxIndex
346cdf0e10cSrcweir				If RemoveItem &lt;&gt; OldList(i) Then
347cdf0e10cSrcweir					NewList(a) = OldList(i)
348cdf0e10cSrcweir					a = a + 1
349cdf0e10cSrcweir				End If
350cdf0e10cSrcweir			Next i
351cdf0e10cSrcweir			oListbox.StringItemList() = NewList()
352cdf0e10cSrcweir		Else
353cdf0e10cSrcweir			oListBox.StringItemList() = NullList()
354cdf0e10cSrcweir		End If
355cdf0e10cSrcweir	End If
356cdf0e10cSrcweirEnd Sub
357cdf0e10cSrcweir
358cdf0e10cSrcweir
359cdf0e10cSrcweirFunction GetItemPos(oListBox as Object, sItem as String)
360cdf0e10cSrcweirDim ItemList()
361cdf0e10cSrcweirDim MaxIndex as Integer
362cdf0e10cSrcweirDim i as Integer
363cdf0e10cSrcweir	ItemList() = oListBox.StringItemList()
364cdf0e10cSrcweir	MaxIndex = Ubound(ItemList())
365cdf0e10cSrcweir	For i = 0 To MaxIndex
366cdf0e10cSrcweir		If sItem = ItemList(i) Then
367cdf0e10cSrcweir			GetItemPos() = i
368cdf0e10cSrcweir			Exit Function
369cdf0e10cSrcweir		End If
370cdf0e10cSrcweir	Next i
371cdf0e10cSrcweir	GetItemPos() = -1
372cdf0e10cSrcweirEnd Function
373*3e02b54dSAndrew Rist</script:module>
374