用VB,把ABC3个数字从大到小排序,高手写下程序,谢谢!
答案:4 悬赏:50 手机版
解决时间 2021-02-24 08:33
- 提问者网友:疯子也有疯子的情调
- 2021-02-23 18:31
用VB,把ABC3个数字从大到小排序,高手请写一下程序。。 详细的,谢谢!!!!感激!!!
最佳答案
- 五星知识达人网友:狂恋
- 2021-02-23 19:27
其实inputbox和容易,新建一个command2按钮,添加代码Private Sub Command1_Click()
a = CInt(InputBox("请输入a的值", "a值输入", "0"))
b = CInt(InputBox("请输入b的值", "a值输入", "0"))
c = CInt(InputBox("请输入c的值", "a值输入", "0"))
End Sub搞定,这样就三个textbox控件也省了
a = CInt(InputBox("请输入a的值", "a值输入", "0"))
b = CInt(InputBox("请输入b的值", "a值输入", "0"))
c = CInt(InputBox("请输入c的值", "a值输入", "0"))
End Sub搞定,这样就三个textbox控件也省了
全部回答
- 1楼网友:时间的尘埃
- 2021-02-23 20:53
冒泡排序:
private sub command1_click()
dim s as string
s = "cab"
for i = 1 to 3
for j = 3 to i + 1 step -1
if asc(mid(s, j, 1)) > asc(mid(s, j - 1, 1)) then
t = mid(s, j, 1)
mid(s, j, 1) = mid(s, j - 1, 1)
mid(s, j - 1, 1) = t
end if
next j, i
print s
end sub
用if和inputbox - -
private sub command1_click()
dim s as string
s = inputbox("输入3个字符")
if asc(mid(s, 1, 1)) < asc(mid(s, 2, 1)) then
t = mid(s, 1, 1)
mid(s, 1, 1) = mid(s, 2, 1)
mid(s, 2, 1) = t
end if
if asc(mid(s, 1, 1)) < asc(mid(s, 3, 1)) then
t = mid(s, 1, 1)
mid(s, 1, 1) = mid(s, 3, 1)
mid(s, 3, 1) = t
end if
if asc(mid(s, 2, 1)) < asc(mid(s, 3, 1)) then
t = mid(s, 2, 1)
mid(s, 2, 1) = mid(s, 3, 1)
mid(s, 3, 1) = t
end if
print s
end sub
- 2楼网友:从此江山别
- 2021-02-23 20:24
Dim numMin As Single
Dim numMid As Single
Dim numMax As Single
numMin = A
numMid = A
numMax = A
If B > numMax Then
numMid = numMax
numMax = B
ElseIf B < numMin Then
numMin = B
End If
If C > numMax Then
numMid = numMax
numMax = C
ElseIf C < numMin Then
numMin = C
End If
- 3楼网友:神的生死簿
- 2021-02-23 20:06
冒泡排序:
Private Sub Command1_Click()
Dim s As String
s = "CAB"
For i = 1 To 3
For j = 3 To i + 1 Step -1
If Asc(Mid(s, j, 1)) > Asc(Mid(s, j - 1, 1)) Then
t = Mid(s, j, 1)
Mid(s, j, 1) = Mid(s, j - 1, 1)
Mid(s, j - 1, 1) = t
End If
Next j, i
Print s
End Sub
用IF和inputbox - -
Private Sub Command1_Click()
Dim s As String
s = InputBox("输入3个字符")
If Asc(Mid(s, 1, 1)) < Asc(Mid(s, 2, 1)) Then
t = Mid(s, 1, 1)
Mid(s, 1, 1) = Mid(s, 2, 1)
Mid(s, 2, 1) = t
End If
If Asc(Mid(s, 1, 1)) < Asc(Mid(s, 3, 1)) Then
t = Mid(s, 1, 1)
Mid(s, 1, 1) = Mid(s, 3, 1)
Mid(s, 3, 1) = t
End If
If Asc(Mid(s, 2, 1)) < Asc(Mid(s, 3, 1)) Then
t = Mid(s, 2, 1)
Mid(s, 2, 1) = Mid(s, 3, 1)
Mid(s, 3, 1) = t
End If
Print s
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯