VB程序(具体操作步骤)
来源:百度知道 编辑:UC知道 时间:2024/06/07 18:01:37
设计一个应用程序,用下拉菜单实现两个数的最大数或最小数
新建窗体,编辑菜单:主菜单名称:compare ;标题:比较大小。在给其设置两个子菜单,分别的名称为“MAX”“MIN”标题为“最大值”“最小值”,确定
然后输入代码:
Option Base 1
Dim arr(2) As Integer
Private Sub Form_Load()
For i = 1 To 2
arr(i) = Val(InputBox("请输入要比较的数:"))
Next i
End Sub
Private Sub max_Click()
Dim max As Integer
max = arr(1)
If max > arr(2) Then
Print "最大值是" & max
Else
max = arr(2)
Print "最大值是" & max
End If
End Sub
Private Sub min_Click()
Dim min As Integer
min = arr(1)
If min < arr(2) Then
Print "最小值是" &a