Help with MultiSelect ListBox

K

Kevin Mayer

Hello

Im kinda new at this VBS programming so please bear with me. What I would
like to be able to with VBS is this:

I have a custom form that I have placed a text box, 2 commandbuttons, and a
listbox (which is populated from an array). When I click one of the
commandbuttons the list box visible property changes to true. What I would
like to happen is when I click the second commandbutton to close the
listbox, the items text properties that have been selected are placed in the
text box. I have the listbox advanced properties set as ListStyle = Option
and the MultiSelect=Multi and cannot get any results listed in the text box.
I am able to accomplish this when it is only a ListStyle=Plain and
MultiSelect=Single, but that only gives me one item. Attached is a snippet
of the code that I am working with. Any help would be appreciated. In
advance, thank you for all of your help

Kevin Mayer

Sub Activity1_Click()

OpenListBox1

End Sub



Function OpenListBox1()

'Fill ListBox1 with Array on Open

varList = Array("POL", "Water", "Heeeelllpppp")

set ctls = Item.GetInspector.ModifiedFormPages("Message").Controls

set ListBox = ctls("ListBox1")

set CloseButton = ctls("CloseButton1")

ListBox.Visible = False

CloseButton.Visible = False

ListBox.list = varList

If ListBox.Visible = False Then

ListBox.Visible = True

If CloseButton.Visible = False Then

CloseButton.Visible = True

Else

ListBox.Visible = False

CloseButton.Visible = False

End If

End If

End Function



Function CloseButton1_Click()

set ctls = Item.GetInspector.ModifiedFormPages("Message").Controls

set ListBox = ctls("ListBox1")

set TextBox1 = ctls("Activity1Text")

set CloseButton = ctls("CloseButton1")

intRows = ListBox.ListCount - 1

myvalue = ListBox.Value

For i = 0 to intRows

If ListBox.Selected(i) = True Then

TextBox1.Text = Myvalue

Else

End If

Next

If ListBox.Visible = True Then

ListBox.Visible = False

If CloseButton.Visible = True Then

CloseButton.Visible = False

Else

ListBox.Visible = False

CloseButton.Visible = False

End If

End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top