OBJECTIVES:
1. Apply comment and statements in Visual Basic Programming.
2. Simulate the importance of comments and statements in program
design and development.
3. Analyze the importance of Visual Basic Functions.
4. Create program using different Functions available in Visual Basic.
THE END STATEMENT
The End statement ends an application immediately. No code after the
Rem
intAge = Val(txtAge.Text)
txtAge.Text
y = IsNumeric(intNumber)
y receives True
FORMAT FUNCTION
The Format() function enables you to format how data are displayed. If
variable total_cost contains the total amount of a product, you might want to
display the value of this variable in currency format (in 2 decimal places with a
currency sign).
2|Page
Format() does not change a value, it only changes the way a value looks.
This function returns a variant. The following is Format()s syntax:
Format(<expression>, <strFormat>)
<expression> can be any variable, expression, or a constant. <strFormat>
may be a value in the following table:
strFormat
Description
Currency
A dollar sign appears before the formatted value. The value has
a comma thousands separator and 2 decimal places. Negative
values are automatically enclosed in parentheses.
Fixed
Displays at least one digit before and two digits following the
decimal point, with no thousands separator.
General
Number
Percent
You can also create your own strFormat. Youll just need a combination
of pound sign and zeros to format values. Each pound sign indicates where a
significant digit goes. The zero indicates that you want either leading or trailing
zeros, whether the zero or significant or not.
Examples:
A = 123.3232
B = 23.0002
C = 12233
D = .34
Format Expression
Result
Format(A, Currency)
$ 123.32
Format(D, Percent)
34%
Format(B, Fixed)
23.00
Format(D, ###)
Nothing
Format(D, ##.###)
.34
3|Page
Format(D,0.000)
0.340
Format(C,#,###.00)
12,233.00
Format(C,#,###.##)
12,233.
Format(C, P #,##0.00)
P 12, 233.00
4|Page