Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help on list and text boxes

mOskimOski Member Posts: 44

I'm making a program that has 2 list boxes and 4 text boxes.In the program if you click an item on one of the list box the first text box's text is equal to a text. Now what I want is that The next time I click on an item on one of the 2 list boxes, the next item will be added to the second text box, then the next click the item will be added to the third text box and so on but everytime I click on an item its always added on the first text box.

I tried everything I know and I still can't do it...

hope someone here can help.....

Comments

  • dokken2dokken2 Member Posts: 532
    [code]
    Private Sub Command1_Click()
    'INIT LIST1
    With Me.List1
    .AddItem "a"
    .AddItem "b"
    .AddItem "c"
    End With
    'INIT LIST2
    With Me.List2
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    End With
    'INIT TEXT1-4
    Me.Text1.Text = ""
    Me.Text2.Text = ""
    Me.Text3.Text = ""
    Me.Text4.Text = ""
    End Sub

    Private Sub List1_Click()
    AddText Me.List1.Text
    End Sub

    Private Sub List2_Click()
    AddText Me.List2.Text
    End Sub

    Private Sub AddText(ByVal txt As String)
    If Me.Text1.Text = "" Then Me.Text1.Text = txt: Exit Sub
    If Me.Text2.Text = "" Then Me.Text2.Text = txt: Exit Sub
    If Me.Text3.Text = "" Then Me.Text3.Text = txt: Exit Sub
    If Me.Text4.Text = "" Then Me.Text4.Text = txt: Exit Sub
    End Sub
    [/code]


    here's a 2nd way-
    AddText "init" to restart adding text to textbox 1-4

    [code]
    Private Sub AddText(ByVal txt As String)
    Static x As Byte
    If txt = "init" Then x = 0:Exit Sub
    x = x + 1
    Select Case x
    Case 1: Me.Text1.Text = txt
    Case 2: Me.Text2.Text = txt
    Case 3: Me.Text3.Text = txt
    Case 4: Me.Text4.Text = txt
    End Select
    End Sub
    [/code]
Sign In or Register to comment.