先设四个TEXT框,再设一个命令按钮C1,程序运行后,在四个TEXT框中,各输入四个不同的数值,当单击一下命令按钮时,则在窗体上显示四个TEXT框中最大值的一个,如图知道的请写下代码!
VB的问题请求解决
- 提问者网友:嗝是迷路的屁
- 2021-07-28 06:18
- 五星知识达人网友:逐風
- 2021-07-28 07:24
Dim a(4) As Integer
a(1) = Text1.Text
a(2) = Text2.Text
a(3) = Text3.Text
a(4) = Text4.Text
Cls
For i = 1 To 4
For j = i + 1 To 4
If a(i) < a(j) Then
a(i) = a(i) + a(j)
a(j) = a(i) - a(j)
a(i) = a(i) - a(j)
End If
Next
Next
Print a(1)
End Sub
- 1楼网友:蕴藏春秋
- 2021-07-28 09:53
Dim a(1 To 4)
a(1) = Text1.Text a(2) = Text2.Text a(3) = Text3.Text
a(4) = Text4.Text
For i = 1 To 3 For j = i + 1 To 4
If a(i) < a(j) Then b = a(i) a(i) = a(j) a(j) = b End If Next j Next i Print "最大值是:" & a(1)
- 2楼网友:慢性怪人
- 2021-07-28 08:47
Private Sub Command1_Click() Dim a(3) As Integer
Dim i As Integer Dim j As Integer
Dim temp As Integer
a(0) = Val(Text1.Text) a(1) = Val(Text2.Text) a(2) = Val(Text3.Text) a(3) = Val(Text4.Text)
For i = 0 To 3 For j = 0 To 2 - i If (a(j) > a(j + 1)) Then temp = a(j) a(j) = a(j + 1) a(j + 1) = temp End If Next j Next i
Print a(3) End Sub