永发信息网

哪位高手能提供一下用VB 比较三个数的大小的编程的过程?

答案:4  悬赏:10  手机版
解决时间 2021-07-20 14:07
  • 提问者网友:浮克旳回音
  • 2021-07-20 00:30
本人为初学者,不知道这个比较大小的程序怎么写,请高手写一下详细的程序过程。谢谢
最佳答案
  • 五星知识达人网友:神的生死簿
  • 2021-07-20 01:27
Option Explicit
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, t As Integer
a = Rnd * 100
b = Rnd * 100
c = Rnd * 100
If a > b Then t = a: a = b: b = t
If a > c Then t = a: a = c: c = t
If b > c Then t = b: b = c: c = t
Print "随机数中产生的最小的数是" & a & "," & "第2小的数是" & b & "," & "最大的数是" & c
End Sub
全部回答
  • 1楼网友:洒脱疯子
  • 2021-07-20 03:08

Private Sub Command1_Click() a = InputBox("请输入第一个数") b = InputBox("请输入第二个数") c = InputBox("请输入第三个数") '这里是判断最小数 If a < b And a < c Then Print "“你输入的最小数是”"; a ElseIf b < a And b < c Then Print "“你输入的最小数是”"; b ElseIf c < a And c < b Then Print "“你输入的最小数是”"; c End If '这里是判断最大数 If a > b And a > c Then Print "“你输入的最大数是”"; a ElseIf b > a And b > c Then Print "“你输入的最大数是”"; b ElseIf c > a And c > b Then Print "“你输入的最大数是”"; c End If End Sub

我也是刚学不久的,希望能帮到楼主.

  • 2楼网友:天凉才是好个秋
  • 2021-07-20 02:58
private sub form1_click() dim a(3) As Integer,I As Integer,J As Integer,B as boolean form1.autoredraw=true a(1)=50 a(2)=9 A(3)=11 print "三个数:" for i=1 to 3 print a(i); next print For I=1 to 3 B=false for J=1 to I-1 if a(j)>a(j+1) then a(0)=a(j) a(j)=a(j+1) a(j+1)=a(0) b=true endif next j if b=false then exit for next i print "按照从小到大的顺序:" for i=1 to 3 print a(i); next end sub
  • 3楼网友:北城痞子
  • 2021-07-20 02:21
Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer, t As Integer a = CInt(InputBox("输入第1个数")) b = CInt(InputBox("输入第2个数")) c = CInt(InputBox("输入第3个数")) If a > b Then t = a: a = b: b = t If a > c Then t = a: a = c: c = t If b > c Then t = b: b = c: c = t Print a & " " & b & " " & c End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯