Académique Documents
Professionnel Documents
Culture Documents
A=2
B=3
C = (A+B) + (A-B)
Textbox1.Text = C
To clear listbox:
Listbox1.Items.Clear()
How to declare:
Dim str As String
str = "Steve Martin"
or str = "814-111-2345"
You need to convert the data to a numeric value before doing any calculations
txtOutput.Text = A
VB adds Cstr for you
txtOutput.Text = Cstr (A)
String Concatenation
Use &
str1 & str2
Ex. Dim str1, str2, str3 As String
str1 = txt1.Text
str2 = txt2.Text
str3 = str1 & str2
txt3.Text = str3
Trim- removes all spaces from front and back of string value
Ex. S = " Hello World "
txtbox.Text = S.Trim --> "Hello World"
S1 = "Steve Martin"
"Michael Goode"
Dim sp As Integer
name = txtName.Text
sp = name.Indexof (" ")
Dim len As Integer
len = name.lengths
LL= len - (sp + 1) --> the # of characters in last name
name.substring ((sp + 1), LL)
Empty string ("")
txtbox.Text = " "
OR
txtbox.Clear ( )
C:\Users\sim.PITT\mydocuments\hello.txt
**If the application file and the text file are placed in the same directory, you don't need to use
the "directory path"
Filename in Window
In windows, file name has 2 parts
filename. filetype ---> mp3, doc
(:|users|sim.PITT| |hello.txt)
**When executable and data are located in the same folder, "directory path" is not
required
Just use the file name
put the data file (hello.txt) in bin/Debug
**Use CDbl or CInt when you read numbers stored in a text file
Ex. a = CDbl ("message, 0, txt6)
Message Dialog Box- A message box is a special dialog box used to display a piece of
information to the user. The user cannot type anything in the dialog box.
Input Dialog Box- Displays a prompt in a dialog box, waits for the user to input text or click a
button, and then returns a string containing the contents of the text box
Font Style
1. monospace- each character uses the same space <Lucida Console>
2. proportional- one character uses more space <Courier New>
**Must use monospace font with zone
If-Block
If condition Then
action 1
Else,
action 2
End If
If condition Then
action 1
Else if condition 2 # of conditions: n-1
action 2 # of actions: n
Else if condition 3
action 3
Else
action n