27 if语句
2018-11-01 本文已影响0人
怪味森
![](https://img.haomeiwen.com/i11511225/29cfb4b7a2023332.png)
多行if语句
![](https://img.haomeiwen.com/i11511225/9acfb21e95a9cd66.png)
![](https://img.haomeiwen.com/i11511225/13786e85a470dfd7.png)
Private Sub Command1_Click()
a = Text3
b = Text4
Text1.Text = Int(Rnd * (a - 1 + 1) + 1)
Text2.Text = Int(Rnd * (b - 1 + 1) + 1)
End Sub
单行else语句
![](https://img.haomeiwen.com/i11511225/9ca185805df1aa87.png)
![](https://img.haomeiwen.com/i11511225/a226eee113025448.png)
![](https://img.haomeiwen.com/i11511225/243caec68428c656.png)
![](https://img.haomeiwen.com/i11511225/0bc750f98c50c407.png)
![](https://img.haomeiwen.com/i11511225/0043eab9721ee4c8.png)
![](https://img.haomeiwen.com/i11511225/027eded73a044a6f.png)
if 嵌套比较三个数大小
Private Sub Command1_Click()
Form1.Cls
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim max As Integer
Randomize
a = Int(Rnd * 100)
b = Int(Rnd * 100)
c = Int(Rnd * 100)
Print "三个随机数是"; a; b; c
If a > b Then
If a > c Then
Print "最大值是"; a
Else
Print "最大值是"; c
End If
Else
If c < b Then
Print "最大值是"; b
Else
Print "最大值是"; c
End If
End If
End Sub