Jump to content

Tutorial - ListBox, ComboBox & Command button.

- - - - -

  • Please log in to reply
17 replies to this topic

#1
travy92

travy92

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
INTRODUCTION
Seeing as i've learned quiet a bit about visual basic, I'd like to introduce you to my second tutorial.
(My first was "Tutorial - SmarterChild Copy")
-------------------------------------------------------------------
WHAT WE'RE DOING
Basically in this mini tutorial we'll learn about adding text to a ListBox using a command button and a combo box/saving search history in combo box.
-------------------------------------------------------------------
GUI (Layout of the form)
This is my GUI (Layout)
Posted Image
You can use any GUI but this is mine.

It consists of:
1 Command Button:
Name: "cmdPrint"
Caption: "Add text to ListBox"

1 ListBox:
Name: "lstList"
Caption: (None)

1 ComboBox:
Name: "cboText"
Caption: (None)

Note: Don't add the quotes in caption/name(").
----------------------------------------------------------------
NAME EXPLANATIONS:
cmdPrint: "cmd" stands for Command, since it's a command button, use cmd. "Print" means Print... Nothing special.. It can be anything you want.

lstList: "lst" stands for List, since it's a ListBox, use lst. List simply means a list.

cboText: "cbo" stands for ComboBox, since it's a ComboBox, use cbo. "Text" means text.
----------------------------------------------------------------
CODE

Quote

Private Sub cmdPrint_Click()
lstList.AddItem cboText.Text
cboText.AddItem cboText.Text
End Sub
This is all that's needed to make this very simply program.
----------------------------------------------------------------
CODE EXPLANATION

Quote

Private Sub cmdPrint_Click()
Basically this means everytime you click cmdPrint, it will do the action as specified (Below)
----------------------------------------------------------------

Quote

lstList.AddItem cboText.Text
This code means add whatever text is written in the cboText.Text box to lstList box.
----------------------------------------------------------------

Quote

cboText.AddItem cboText.Text
This code means add the text that's written in cboText box into the cboText box... (So like saving history... This function can be used for an internet browser... I may be writing a tutorial on making an internet browser, if you want)
----------------------------------------------------------------

Quote

End Sub
This needs to be added at the end of every code.
---------------------------------------------------------------------------------
And you're done!
Posted Image
This is the example of the product with text in the ListBox.

And another one with the text saved in the ComboBox (Or History if you will):
Posted Image
---------------------------------------------------------------------------------
So this is goodbye for now.

This tutorial was made by me, Travy92.

Special thanks to Tcm9669 for the Screenshot program.

EDIT - I'll include some samples for the lazy people..

Attached Files



#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
These are nice tutorials that you are making, and I noticed that you used a program from here to make screenshot so I modified it for you so whn you press Start or CTRL+S it will hide the window and when you press CTRL+E It will stop taking screens and the window will show again. Hope you like it, download it from here:

http://forum.codecal...-screen-v2.html

#3
travy92

travy92

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
Oh man, i can't thank you enough! Wonderful !

#4
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
No problem, hope you use it in your next tutorial. I fixed it btw, download it again.

#5
Lukica

Lukica

    Newbie

  • Members
  • Pip
  • 1 posts
Thank you ... I was looking for this

#6
sammy..the..great

sammy..the..great

    Newbie

  • Members
  • Pip
  • 1 posts
Thanks for this! I think I'm going to find this very useful, and now, my post count is one I should be able to download it! lol :-)

#7
Bigig

Bigig

    Newbie

  • Members
  • Pip
  • 1 posts
Thanks for this, this will be very helpful.

-BigIg

#8
jodlajodla

jodlajodla

    Newbie

  • Members
  • Pip
  • 1 posts
dan

#9
tigersubu

tigersubu

    Newbie

  • Members
  • Pip
  • 2 posts
....

#10
tigersubu

tigersubu

    Newbie

  • Members
  • Pip
  • 2 posts
.


COMBOBOX in HTML

Try the code for COMBOBOX in HTML : Editable DropDown Listbox with any one select option as Editable (like a textbox ) and the rest as readonly.

http://chakrabarty.c...e_dropdown.html

http://chakrabarty.com/combobox.html

.. it is a typeable combobox.



.



.

#11
Abaset

Abaset

    Newbie

  • Members
  • Pip
  • 1 posts
Good man

Hellio to all

Edited by WingedPanther, 04 August 2009 - 06:04 AM.
Double post


#12
unleashed-my-freedom

unleashed-my-freedom

    Newbie

  • Members
  • Pip
  • 8 posts
what is the different between combo box, text box, label?
Thank You




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users