
vb 比较3个数的大小 20
if语句这么用?谢谢!不调用这么弄?<scriptlanguage="vbscript">dimadimbdimcdimta=cint(inputbox("请输入第1个数...
if 语句这么用?
谢谢!
不调用这么弄?
<script language="vbscript">
dim a
dim b
dim c
dim t
a=cint(inputbox("请输入第1个数: "))
b=cint(inputbox("请输入第2个数: "))
c=cint(inputbox("请输入第3个数: "))
if a>b then
t=a a=b b=t
else
if b>c
then t=b b=c c=t
else if a>c then
t=a a=c c=t
end if
msgbox a&"<"&b&"<"&c
</script>错了? 展开
谢谢!
不调用这么弄?
<script language="vbscript">
dim a
dim b
dim c
dim t
a=cint(inputbox("请输入第1个数: "))
b=cint(inputbox("请输入第2个数: "))
c=cint(inputbox("请输入第3个数: "))
if a>b then
t=a a=b b=t
else
if b>c
then t=b b=c c=t
else if a>c then
t=a a=c c=t
end if
msgbox a&"<"&b&"<"&c
</script>错了? 展开
4个回答
展开全部
另一种加文本框比较方法
首先在VB添加三个文本框(TEXT)
和一个命令按钮(COMMAND)
Private Sub COMMAND1_CLICK()'这里是CLICK不是LOAD,看清除
Dim A As Integer '定义三个数
Dim B As Integer
Dim C As Integer
A = Val(Text1.Text) '把三个数的值化成数字型的
B = Val(Text2.Text)
C = Val(Text3.Text)
If A > B Or A > C Then ' 比较三个数大小,假如是哪个数最大就显示哪个数
MsgBox "最大的数是" & A
ElseIf B > A Or B > C Then
MsgBox "最大的数是" & B
ElseIf C > A Or C > B Then
MsgBox "最大的数是" & C
Else
End
End If '结束语句
End Sub
很简单的,自己试下吧
也可以直接把我的代码复制就可用了
别忘了添加控件啊
嘿嘿
首先在VB添加三个文本框(TEXT)
和一个命令按钮(COMMAND)
Private Sub COMMAND1_CLICK()'这里是CLICK不是LOAD,看清除
Dim A As Integer '定义三个数
Dim B As Integer
Dim C As Integer
A = Val(Text1.Text) '把三个数的值化成数字型的
B = Val(Text2.Text)
C = Val(Text3.Text)
If A > B Or A > C Then ' 比较三个数大小,假如是哪个数最大就显示哪个数
MsgBox "最大的数是" & A
ElseIf B > A Or B > C Then
MsgBox "最大的数是" & B
ElseIf C > A Or C > B Then
MsgBox "最大的数是" & C
Else
End
End If '结束语句
End Sub
很简单的,自己试下吧
也可以直接把我的代码复制就可用了
别忘了添加控件啊
嘿嘿
展开全部
就这样了
Dim a
Dim b
Dim c
Dim t
a = CInt(InputBox("请输入第1个数: "))
b = CInt(InputBox("请输入第2个数: "))
c = CInt(InputBox("请输入第3个数: "))
If a > b Then
t = a
If a > c Then
t = a
If b > c Then
MsgBox a & ">" & b & ">" & c
Else
MsgBox a & ">" & c & ">" & b
End If
Else
t = c
If a > b Then
MsgBox c & ">" & a & ">" & b
Else
MsgBox c & ">" & b & ">" & a
End If
End If
Else
t = b
If b > c Then
t = b
If a > c Then
MsgBox b & ">" & a & ">" & c
Else
MsgBox b & ">" & c & ">" & a
End If
Else
t = c
If a > b Then
MsgBox c & ">" & a & ">" & b
Else
MsgBox c & ">" & b & ">" & a
End If
End If
End If
Dim a
Dim b
Dim c
Dim t
a = CInt(InputBox("请输入第1个数: "))
b = CInt(InputBox("请输入第2个数: "))
c = CInt(InputBox("请输入第3个数: "))
If a > b Then
t = a
If a > c Then
t = a
If b > c Then
MsgBox a & ">" & b & ">" & c
Else
MsgBox a & ">" & c & ">" & b
End If
Else
t = c
If a > b Then
MsgBox c & ">" & a & ">" & b
Else
MsgBox c & ">" & b & ">" & a
End If
End If
Else
t = b
If b > c Then
t = b
If a > c Then
MsgBox b & ">" & a & ">" & c
Else
MsgBox b & ">" & c & ">" & a
End If
Else
t = c
If a > b Then
MsgBox c & ">" & a & ">" & b
Else
MsgBox c & ">" & b & ">" & a
End If
End If
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function
max(a
as
integer,
b
as
integer)
as
integer
'定义一个求两个数最大数的函数,利用它求多个
if
a
>
b
then
max
=
a
else
max
=
b
end
if
end
function
private
sub
command1_click()
dim
a
as
integer,
b
as
integer,
c
as
integer,
d
as
integer
a
=
val(text1.text)
b
=
val(text2.text)
c
=
val(text3.text)
d
=
val(text4.text)
dim
t
as
integer
't
=
max(max(max(a,
b),
c),
d)
'这样写也可以
t
=
max(a,
max(b,
max(c,
d)))
text5.text
=
t
end
sub
max(a
as
integer,
b
as
integer)
as
integer
'定义一个求两个数最大数的函数,利用它求多个
if
a
>
b
then
max
=
a
else
max
=
b
end
if
end
function
private
sub
command1_click()
dim
a
as
integer,
b
as
integer,
c
as
integer,
d
as
integer
a
=
val(text1.text)
b
=
val(text2.text)
c
=
val(text3.text)
d
=
val(text4.text)
dim
t
as
integer
't
=
max(max(max(a,
b),
c),
d)
'这样写也可以
t
=
max(a,
max(b,
max(c,
d)))
text5.text
=
t
end
sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
呵呵!
if a>b then
T=a
else
T=b
endif
if T<c then
T=c
endif
最后输出 T 就是三者最大的
if a>b then
T=a
else
T=b
endif
if T<c then
T=c
endif
最后输出 T 就是三者最大的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |