0402 Private Sub Command1_Click() Dim a As Single,b As Single Dim c As Single,d As Single Dim m A0401Private Sub Form_Load()Dim x As Long,s As Stringx = InputBox("输入一个整数(1~40000)")If x Mod 2 = 0 Thens = "偶数"Elses = "奇数"End IfMsgBo
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/04 02:53:19
0402 Private Sub Command1_Click() Dim a As Single,b As Single Dim c As Single,d As Single Dim m A0401Private Sub Form_Load()Dim x As Long,s As Stringx = InputBox("输入一个整数(1~40000)")If x Mod 2 = 0 Thens = "偶数"Elses = "奇数"End IfMsgBo
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
0402 Private Sub Command1_Click() Dim a As Single,b As Single Dim c As Single,d As Single Dim m A0401Private Sub Form_Load()Dim x As Long,s As Stringx = InputBox("输入一个整数(1~40000)")If x Mod 2 = 0 Thens = "偶数"Elses = "奇数"End IfMsgBo
你好像是查询abcd四个数的最大数,你使用的这个方法不理想,在VB中一般使用排序进行判断,排序是将数据存储在数组中,你的程序可以定义一个数组,然后进行排序:
Private Sub Command1_Click()
Dim a(1 To 4) As Single,x As Single
a(1) = Val(Text1.Text):a(2) = Val(Text2.Text):a(3) = Val(Text3.Text):a(4) = Val(Text4.Text)
For i = 1 To 3
For j = 1 To 4 - i
If a(j) < a(j + 1) Then
x = a(j)
a(j) = a(j + 1)
a(j + 1) = x
End If
Next j
Next i
Text5.Text = "最大值是:" & CStr(a(1)) & ",最小值是:" & CStr(a(4))
End Sub