/  3
 
 SEB’s VB.NET Guide
Accepting User Input
Basic Text
1.Add a text box2.Delete the text in the text property3.Write the code to process the user input:
What do you want to activate the code? Use a
form_load
to automatically run thecode or a
command
#
 _click 
to run it when the user clicks the command button.
(The sub will be created for you if you double-click on the command button or the form)
Example:
Private Sub Command
1
 _Click If 
Text1.Text = “Hello!”
 
Then
Text1.Text = “Welcome”
ElseIf 
Text1.Text = “Good-bye”
 
Then
Text1.Text = “See ya!”
Else
Text1.Text = “Sorry. I don’t understand.”
End If End Sub
List Boxes, Check Boxes, Combos & OptionButtons
List Boxes:
List boxes allow the user to select from several options in a box.The user can only choose one from the selected list.
Check Boxes
Check boxes allow the user to tick the options they want to choose. They canselect more than one box.
 Page 1 of 3
 
 SEB’s VB.NET Guide
Combos
Combos allow the user to select from a dropdown box
Option Buttons
Option buttons allow the user to choose between the options available.
Using Combos & Lists
1.Build the list of options in your combo or list by adding them in a
form_load
or 
command
#
 _click 
:
List
#
.AddItem
 
“Option”
 or 
Combo
#
.AddItem
 
“Option”
(where
is the number of the option and
option
is the name of the choice)2.Use an IF statement or a case statement to set to code the effect of the user’s choice.
If 
 
 List#.ListIndex = 0
Then
 Image1.Visible = True
ElseIf 
 List#.ListIndex = 1
Then
 Image2.Visible = True
Else
 Image3.Visible = True
End If 
This code assumes all images have previously been set to
visible = false
. The
ListIndex
numbers the options in the list, starting with 0. The
case statement 
issimilar to IF: it is designed for use with a large number of options. The followingcase statement would work in the same way.
 Page 2 of 3

Share & Embed

More from this user

Add a Comment

Characters: ...