PDA

View Full Version : Adding item in listbox 1



volabos
12-03-2007, 09:25 AM
Suppose, I have a userform and on this userform, I have a listbox, name it listbox1, containing 4 elements : A, B, C, and D.

However instead of working directly with A, B, C or D, user might want to work with their simple functions.
For example he may want to work with A, B, A-D, A-C. Therefore i have to "invent" some way so that user can enter those choices.

I thought of following:
On the same userform, just beside of listbox1, there will be a textbox. But user can not write anything by using keyboard, except the mathematical signs. He will only have choice to enter data from the listbox1 entries.

Fo the current example, in that textbox user can write : A,B,A-D,A-C. Here he will take A, B etc from listbox1 and '-' ',' signs can be entered through keyboard.

Can anyone help me to write a VBA code for doing this job? Your help will be highly appreciated.

Thanks and Regards,
:banghead:

Bob Phillips
12-03-2007, 09:27 AM
Just give them a multi-select listbox.

volabos
12-03-2007, 09:53 AM
Hi Xld, can you please tell me how i can move the items from listbox to next textbox. If possible, can you provide me a skeleton on codes for doing that?

Regards,

figment
12-03-2007, 10:19 AM
this idea is unresonable for large sets of data, but if you only have 4 options, you could just generat all posiblilies and put them in the list.

volabos
12-03-2007, 11:10 AM
If anyone here please provide me any guidence on how to move the list-items to text box then I can start experimenting.

Regards,

Bob Phillips
12-03-2007, 11:46 AM
Dim mpText As String
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
mpText = mpText & .List(i) & Chr(10)
End If
Next i
End With
Me.TextBox1.Text = mpText