Вы находитесь на странице: 1из 4

Two Examples Programs:

These two programs will show the loop feature in Visual Basic.
First I will show the screen shots of my programs and then the
Code.
1)

B=1
Do Until B = 4
MsgBox(B)
B=B+1
Loop
The above code shows the looping feature of VB and below is
the code for the three buttons:
2) Now the second example. This program will show the
features of conditional statement:

If CHBOption1.Checked Then

PBBar1.Value = PBBar1.Value + 1

ElseIf CHBOption2.Checked Then

PBBar1.Value = PBBar1.Value - 1
End If

If PBBar1.Value >= 100 Then

TmrRun.Enabled = False

End If

The above code shows the conditional statement feature.

Table of All Variables Needed By a Program:

Data Description of Size Reason for choosing Visual Basic Declaration:


Type: variable: data type:

Integer Holds 32 bit integers that The value I am using Dim Animals As Integer
4Bytes
range does not contain Animals = 37500000
from the value of fractional numbers
-2,147,483,648
Through 2,147,483,647

String Variable length string Strings are used when Dim Wolf As String
Depends on
can hold from text is involved Wolf = "starter"
0 to 2 billion characters platform

Date Starts from January 1 - Dim Birthday as Date


8Bytes Dates are used when for
0001, through Birthday = 13/02/1992
to December 31 - 9999 example a
birthday date needs to
be set

Single 32 bit number ranging When fractional numbers Dim Price As Single
4Bytes
from -3.4028235E38 are used with this range, Price = 699.99
through 3.4028235E8 this data type is most
efficient to use
Only has true states . Normally used for Private Sub Text3_Change()
Boolean Depends on
which are true and false example when you only Dim a Enable As Boolean
platform
want one command to be
enabled

Вам также может понравиться