0402 Private Sub Command1_Click() Dim a As Single,b As Single Dim c As Single,d As Single Dim m A

问题描述:

0402 Private Sub Command1_Click() Dim a As Single,b As Single Dim c As Single,d As Single Dim m A
0401
Private Sub Form_Load()
Dim x As Long,s As String
x = InputBox("输入一个整数(1~40000)")
If x Mod 2 = 0 Then
s = "偶数"
Else
s = "奇数"
End If
MsgBox s
End Sub
Private Sub Command1_Click()
Dim a As Single,b As Single
Dim c As Single,d As Single
Dim m As Single,n As Single,x As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a > b Then
m = a
Else
m = b
End If
If c > d Then
n = c
Else
n = d
End If
If m > n Then
x = m
Else
x = n
End If
Text5.Text = x
End Sub

你好像是查询abcd四个数的最大数,你使用的这个方法不理想,在VB中一般使用排序进行判断,排序是将数据存储在数组中,你的程序可以定义一个数组,然后进行排序:Private Sub Command1_Click()Dim a(1 To 4) As Single,x A...