You are on page 1of 6

1

, ,
, .
( )
, .

-
. , ,
.
: Price<100 True(), Price -
100, False(), Price , - 100.
:

=

<>

>
-
<
-
>=
-
<=
-

, True False, ,
True False .
, ,
Dim As Boolean.
.

10<>20
True(10 20)
Score<20
True, Score - 20, False
Score=Label1.Caption True, Caption Label1 ,
Score, False
True, Bill , False
Text1.Text=Bill
If . . . Then
, , ,
.
If . . . Then
. - , :
If Then VB.
:
If Score>=20 Then Label1.Caption=You win!
,
If Score>=20 ,
Caption Label1 You
win!. Score , - 20, VB
Caption,
. True False.
.

If . . . Then
Visual Basic If . . . Then,
.
ElseIf, Else End If.

2
If 1 Then
1(condition1) True
ElseIf 2 Then
2(condition2) True
[ ElseIf ]
Else
, True
End If
1(condition1) . True,
, - (
). True, 2
(condition2). True .
ElseIf , .
True, Else.
End If.
If . . . Then
.
: VB,
.
.

246,50
15%
246,51 597,50 .
36,97 + 28% 246,51
597,51 1246,50
135,25 + 31% 597,51
1246,51 2710,50
336,44+36% 1246,51
2710,51
863,48+39% 2710,51
If zaplata <=246,50 Then
DOD=zaplata*0,15
15%
ElseIf zaplata<=597,50 Then
DOD=36,97+((zaplata-246,51)*0,28) 28%
ElseIf zaplata<=1246,50 Then
DOD=135,25+((zaplata-597,51)*0,31) 31%
ElseIf zaplata<=2710,50 Then
DOD=336,44+((zaplata-1246,51)*0,36) 36%
Else
DOD=863,48+((zaplata-2710,51)*0,39) 39%
End If
If . . . Then ElseIf .
,
, . :
, .
zaplata
, True,
.
If Then
If . . . Then, ,
( ).
Private Sub Command1_Click()
Private Sub Command1_Click()
UserName = InputBox(" :") '
' InputBox
' -
If UserName = "Agent_007" Then '
' "Agent_007"

MsgBox (", Agent_007! PC?")


' MsgBox -
' ", Agent_007! PC?"
Form1.Picture = _
LoadPicture("c:\vb6\pcomputr.wmf")
'
ElseIf UserName = "UserM" Then '
'"UserM" -
MsgBox (",UserM! Rolodex?")
' MsgBox -
' ",UserM! Rolodex?"
Form1.Picture = _
LoadPicture("c:\vb6\rolodex.wmf")
'
Else
MsgBox (" , .")
'
' MsgBox " , ."
End 'quit the program
End If
End Sub

Visual Basic If . . .Then
ElseIf, .
:

And
Or
Not
Xor

True, True
True, True
False, True. True,
False.
True, True.
True False, False.


, ,
, .
. ,
Vaucher Bike, Price 200.

Vaucher=Bike And Price<300
Vaucher=Car Or Price<500
Not Price<100
Vaucher=Bike Xor Price<300

True, True
True, True
False, True.
True , False.

Login.vbp, o
.
If . . . Then ElseIf , And
.
And
Login.vbp InputBox If . . . Then
Command1_Click :
Pass=InputBox( .)
If . . . Then :

4
If UserName="Agent_007" And
Pass=A007 Then
, ,
.
ElseIf
ElseIf UserName=UserM And Pass=Marc Then
And Marc .
MyPass.vbp, a MyPass.frm.

Private Sub Command1_Click()


UserName = InputBox(" :")
Pass = InputBox("Enter your password.")
If UserName = "Agent007" And Pass = "A007" Then
MsgBox (", Agent_007! PC?")
Form1.Picture = _
LoadPicture("c:\vb6sbs\less06\pcomputr.wmf")
ElseIf UserName = "UserM" And Pass = "Marc" Then
MsgBox (",UserM! Rolodex?")
Form1.Picture = _
LoadPicture("c:\vb6sbs\less06\rolodex.wmf")
Else
MsgBox (" , .")
End '
End If


InputBox, PasswordChar, ,
(*), MaxLength,
.
Select Case
Visual Basic
Select Case. If . . . Then . ElseIf, -,
, .
Select Case .
Select Case variable ()
Case value1 ()
, value1 variable
Case value2
, value2 variable
Case value3
, value3 variable
.
.
.
End Select
Select Case End
Select. variable , ,
( ) , value1, value2 value3 , ,
, .
, Case VB
End Select. Select Case
Case, Case.
, .

5
1:
Select Case Age
Case 16
Label1.Caption=
Case 18
Label1.Caption=
Case 21
Label1.Caption=
Case 65
Label1.Caption=
End Select
Select Case Case Else,
, . :
2:
Select Case Age
Case 16
Label1.Caption=
Case 18
Label1.Caption=
Case 21
Label1.Caption=
Case 65
Label1.Caption=
Case Else
Label1.Caption= ! !
End Select
Select Case
Visual Basic ,
Select Case. Visual Basic,
: =, <>, <, >, <= >=. ,
Is To. Is ,
Is. To . Is, To
, Age :
3:
Select Case Age
Case Is<13
Label1.Caption= !
Case 13 19
Label1.Caption= !
Case 21
Label1.Caption=
Case Is >100
Label1.Caption=! !
Case Else
Label1.Caption= ! !
End Select
Select Case e If . . . Then . . . ElseIf
, (3) ,
. - ,
, - If . . . Then.
Select Case,
. List1.Text List1.ListIndex,
, Select Case .
Select Case

6
1. Label1
, .
2. , ListBox .
3. ,
.
4. .
5. :

Caption
International Welcome Program
Label1
Font
Times New Roman, Bold, 14
Label2
Caption
Choose a country
Label3
Caption

Caption

Label4
BordrStyle
1-Fixed Single
ForeColor
(&H00000080&)
Command1 Caption
Quit
6. Form_Load.
List1.AddItem England
List1.AddItem German
List1.AddItem Spain
List1.AddItem Italy
. AddItem
, .
7. List1_Click, ,
:
Label3.Caption=List1.Text
Select Case List1.ListIndex
Case 0
Label4.Caption=Hello,programmer
Case 1
Label4.Caption=Hallo,programmierer
Case 2
Label4.Caption=Hola,programador
Case 3
Label4.Caption=Ciao,programmator
End Select

. List1.Text, ,
. Select Case List1.ListIndex
. ListIndex ,
; - 0, 1, 2 .. ListIndex,
.
8. Command1_Click :
End