MSFN Forum: [vb] How To Add Item To A Listbox - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[vb] How To Add Item To A Listbox Rate Topic: -----

#1 User is offline   Doggie 

  • I'm very inactive :(
  • Group: Patrons
  • Posts: 2,676
  • Joined: 13-October 02

Posted 11 April 2003 - 07:28 AM

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 :)


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy