VB上机题:设计程序,在窗体上建5个文本框和一个命令按钮

设计程序,在窗体上建5个文本框和一个命令按钮,利用4个文本框输入4个数,单击命令进行处理,求出这4个数中的最大数,把最大数显示在第5个文本框中。非常感谢!有悬赏币哦~

第1个回答  推荐于2016-07-26

按纽中的程序如下:

 

 dim maxNum as Double

 

 maxNum=Val(Text1)

 If maxNum<Val(Text2) Then maxNum=Val(Text2)

 If maxNum<Val(Text3) Then maxNum=Val(Text3)

 If maxNum<Val(Text4) Then maxNum=Val(Text4)

 

 Text5=Str(maxNum)

可以下载附件中的Form12 源程序...

本回答被提问者采纳
第2个回答  2013-12-07
Private Sub Command1_Click()
Dim A, B As Double
If Val(Me.Text1.Text) - Val(Me.Text2) > 0 Then
A = Me.Text1
Else
A = Me.Text2.Text
End If
If Val(Me.Text3.Text) - Val(Me.Text4) > 0 Then
B = Me.Text3
Else
B = Me.Text4.Text
End If
If A - B > 0 Then
Me.Text5 = A
Else
Me.Text5.Text = B
End If

End Sub
相似回答