用VB,把ABC3个数字从大到小排序,高手写下程序,谢谢!
4个回答
2013-04-16
展开全部
冒泡排序:
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
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
2013-04-16
展开全部
其实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控件也省了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-16
展开全部
你说详细点,怎么个排法?怎么输出排列结果?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询