ListBox Control in Visual Basic 6.0

with 1 Comment

Add items is a very important program in visual basic because without add an item you can not sell it anymore through a program. So today we will discuss on ListBox control in visual basic 6.0.


ListBox control in visual basic 6.0: Create a Program in VB to sell any item from Product List

Step 1: –

  • At first open Visual Basic 6.0 application software
  • Then click on or select ‘Standard EXE’ icon from New Project dialog box
  • Then click on ‘Open’.

Step 2: –

Form Design: –

Select necessary Control Tool from Tool Box and adjust the position to ‘Form Window’: –

  • One Combo Box
  • One List Box
  • Four Command Box

ListBox control in visual basic 6.0

Step 3: –

   Properties Settings: –

  • Select ‘Form1’from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Form1’ to ‘Add Item Project’ from properties window
  • Then select ‘Command1 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command1’ to ‘ADD’ from Properties Window.
  • Then select ‘Command 2 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command 2’ to ‘REMOVE’ from Properties Window.
  • Then select ‘Command 3 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command3’ to ‘CLEAR’ from Properties Window.
  • Then select ‘Command 4 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command 4’ to ‘CANCEL’ from Properties Window.

ListBox Control in Visual Basic
add-item-program

add-item-program

add-item-program

Step 4: –

Code Writing:-

  • Double click on ‘FORM 1’
  • Then input code to Form 1 code box

Code: – With Combo1

   .AddItem “Hard Disk”

  .AddItem “Floppy Disk”

  .AddItem “RAM”

  .AddItem “SMPS”

  End With

  Combo1.ListIndex = 0

  • Then double click on ‘ADD button’ or ‘Command 1 box’
  • Then input code to Command 1 code box.

Code: – List1.AddItem Combo1.Text

  • Then double click on ‘REMOVE button’ or ‘Command 2 box’
  • Then input code to Command 2 code box.

Code: – List1.RemoveItem List1.ListIndex

  • Then double click on ‘CLEAR button’ or ‘Command 3 box’
  • Then input code to Command 3 code box.

Code: – List1.Clear

  • Then double click on ‘EXIT button’ or ‘Command 4 box’
  • Then input code to Command 4 code box.

Code: – End

code for listbox control in visual basic

  • Then close code box

Step 5: –

Project Save: –

  • Click on ‘Save project’ option from File menu
  • Then input any name to file name box and click on Save option from Save file as box
  • Then input any new name to file name box
  • Then click ‘Save’ option.

Step 6: –

   Project Run: –

  • Press F5 key from keyboard or click on ‘Start’ from ‘Run menu’ for run the project
  • Then Click on “Combo 1 box” and select any Item name.
  • Then Click on “ADD” Button.
  • Then select any Item name from “List1 box”.
  • Then click on “REMOVE” Button.
  • Then Click on “CLEAR” Button to clear “List1 box” and click “CANCEL” Button to exit run window.

add-item-program

This is how you can add items in VB on ListBox control in visual basic 6.0. Hope you got a clear idea.







Related Posts:

One Response

  1. Koushik Saha
    | Reply

    More Sir,

Leave a Reply