.


:




:

































 

 

 

 


If.Then.. Else




If...Then.. Else . If...Then

If Then

End If

ij : If , True, , Then. False, :

If Then

1

Else

2

End If

Private Sub Command1_Click()

a = 6

If a = 7 Then

Print "visual"

Else

Print "basic"

End If

End Sub

. .

Private Sub Command1_Click()

a = Val(Text1.Text)

b = Val(Text2.Text)

c = Val(Text3.Text)

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Max = a

If b > Max Then Max = b

If c > Max Then Max = c

Print Max

Min = a

If b < Min Then Min = b

If c < Min Then Min = c

If a < Max And a > Min Then Print a

If b < Max And b > Min Then Print b

If c < Max And c > Min Then Print c

Print Min

End Sub

If 1 Then

1

ElseIf 2 Then

2

Else

3

End If

. ϳ .

Private Sub Command1_Click()

Dim z, n As Integer

z = Val(Text1.Text)

If z <= 200 Then

n = z * 0.15

ElseIf z >= 200 And z <= 500 Then

n = z * 0.2

Else

n = z * 0.28

End If

Label3.Caption = Str(n)

End Sub

, , , , . . .

 

 

30. Select Case. . .

Visual Basic Select Case, . Select Case :

Select Case

Case 1

1

Case 2

2

Case Else

End Select

Case (1), , (2, 3). (4 6) (Is >= 9). (Is=3). Case Else , .

Private Sub Command1_Click()

n = Int(Rnd * 10) + 1 { }

Select Case n

Case 1

Print " internet"

Case 2

Print ""

Case 3

Print "basic"

Case Else

Print "Ivanenko"

End Select

End Sub

 

 

31. Visual Basic. . .

. Visual Basic : For... Next, , Do... Loop, .

For...Next :

For ˳ = ʳ

Next ˳

˳ . ˳ 1 . (, 䒺 ) ʳ , . г , , .

: 1 10.

Private Sub Command1_Click()

For i = 1 To 10

Print i

Next i

End Sub

Exit For.

Do...Loop

, Do... Loop. Do...Loop.

,

D {While | Until}

Loop

,

Do

Loop {While | Until}

, . , , , . Do... Loop .

While...Wend

While... Wend .

While

Wend

䳿 , Do While.. Loop. Do... Loop. , While...Wend Exit.

Private Sub Command1_Click()

While x = True

Print Time

Wend

End Sub

: 20.

Private Sub Command1_Click()

For i = 1 To 9

For j = 1 To 9

For k = 1 To 9

s = i + j + k

If s = 20 Then Print i; j; k

Next k

Next j

Next i

End Sub

.

 

Private Sub Command1_Click()

s = 1: x = 1

n = 1: y = 0.1

f = 1

e = 0.001

While y >= e

For i = 1 To n

f = f * i

Next i

y = x ^ n / f

s = s + y

n = n + 1

f = 1

Wend

Label2.Caption = Str(s)

End Sub





:


: 2015-11-05; !; : 623 |


:

:

,
==> ...

1880 - | 1718 -


© 2015-2024 lektsii.org - -

: 0.014 .