Adding Items in a ListBox

In Visual Basic.Net, items can also be added at runtime using the Add( ) method. We can apply this method in Visual Basic 2017, Visual Basic 2015, Visual Basic 2013, Visual Basic 2012, Visual Basic 2010 as well as Visual Basic 2008.

The syntax of the Add() method is as follows:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 ListBox1.Items.Add(text)
End Sub

Example:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
     ListBox1.Items.Add(“Apple”)
End Sub

The Output is as shown below:

 

Besides that, we can also allow the user to add items via a popup input box.

In the following example, we create a variable myitem and then assign a value to myitem via the InputBox function that store the input from the user. We then use the Add() method to add the user’s item into the listbox. The code is as follows:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myitem                        'declare the variable myitem 
 myitem = InputBox("Enter your Item")
ListBox1.Items.Add(myitem)
End Sub

For more examples, refer to
http://www.vbtutor.net/vb2017/VB2017_Lesson6.html

Visual Basic 2008 Made Easy Paperback has been released!

Visual Basic 2008 Made Easy is written by Dr. Liew, the webmaster of our popular online Visual Basic Tutorial, vbtutor.net. This book is a comprehensive guide to mastering Visual Basic 2008, from beginner to intermediate programmers.  This book has been written to complement our free online Visual Basic 2008 tutorial with much more content. It is also an excellent reference text for high school or college-level computer science courses.

Reading this book will allow you to:

  1. Understand the basic concepts of Visual Basic 2008 programming
  2. Create your own Visual Basic 2008 applications from scratch
  3. Get inspiration from a variety of interesting sample programs
  4. Modify the code samples easily to suit your needs
  5. Learn how to package and distribute your applications

Check out the book on Amazon.com

Visual Basic 2015 Made Easy has been Released Today!

We have released another Visual Basic Made Easy Series book, Visual Basic 2015 Made Easy.




Price: $28.00

AUTHOR: DR. LIEW VOON KIONG

Visual Basic 2015 Made Easy is written by Dr. Liew, the webmaster of our popular online Visual Basic Tutorial, vbtutor.net. This book is a complete guide to mastering Visual Basic 20157, from beginner to intermediate programmers.  This book has been written to complement our free online Visual Basic 2017 tutorial with much more content. It is also an excellent reference text for high school or college-level computer science courses. 

Reading this book will allow you to:  

  1. Understand the basic concepts of Visual Basic 2015 programming
  2. Create your own Visual Basic 2015 applications from scratch
  3. Get inspiration from a variety of interesting sample programs
  4. Modify the code samples easily to suit your needs
  5. Learn how to package and distribute your applications

Preview the Book

Visual Basic 2013 Made Easy Paperback is released today!

Our New Visual Basic 2013 Made Easy Paperback is released today!

Visual Basic 2013 Made Easy  is now available in the paperback version where you can hold and read!  Our tutor Dr.Liew has revamped the digital book by redesigning the formats to make it more reader-friendly. Besides that, he has added a few more topics like drawing the quadratic curve, drawing the sine curve, deploying your VB2013 applications and more.

This book is a complete guide to mastering Visual Basic 2013, from beginner to intermediate programmers.  This book has been written to complement our free online Visual Basic 2013 tutorial . It is also an excellent reference text for high school or college-level computer science courses.

Reading this book will allow you to:

  1. Understand the basic concepts of Visual Basic 2013 programming
  2. Create your own Visual Basic 2013 applications from scratch
  3. Get inspiration from a variety of interesting sample programs
  4. Modify the code samples easily to suit your needs
  5. Learn how to package and distribute your applications

Check it out on Amazon.com

Visual Basic Sample Code Paperback book is released!

Visual Basic sample code paperback book is released on Amazon.com today!

We have revamped the book in terms of design and made the codes more reader-friendly. You can preview our book with the new design by following the link below:

Preview.pdf

Visual Basic Samples Codes is written by our webmaster cum tutor, Dr.Liew. It comprises 258 pages of captivating contents and 48 fascinating Sample Codes. All the examples are explained in great details using straightforward language and illustrated with gorgeous Images. On top of that, you can download the ORIGINAL SOURCE CODE for every sample in the book! By reading the book and using the sample source code, you will be able to master Visual Basic programming effortlessly!

By reading this book and trying out the accompanied source codes, you can:

  • Understand basic to intermediate concepts of Visual Basic programming
  • Create your own Visual Basic programs right from the beginning
  • Get programming ideas from 48 interesting sample programs.
  • Modify the source codes easily to suit your need

Check out our paper book here!