Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

[vb] How To Add Item To A Listbox

- - - - -

  • Please log in to reply
No replies to this topic

#1
Doggie

Doggie

    I'm very inactive :(

  • Patrons
  • 2,676 posts
Requirements: Visual Basic(of course), Listbox control, textbox and command button

Listbox is where the item will go, Textbox is the item text and command button to add it to the list

Under the textboxes Change event add
Private Sub textboxname_Change()
    If Text1.Text = "" Then
        Command1.Enabled = False
        Else
        Command1.Enabled = True
    End If
End Sub
If Text1.Text = "" Then <== This is saying if theres no text in the textbox then it will make the command button disabled

Under the Command button Click event
Private Sub Command1_Click()
    List1.AddItem Text1.Text
End Sub
List1.AddItem Text1.Text <== Simply means add item to the list with the text in the textbox

Simple :)


How to remove advertisement from MSFN



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN