VB.NET中,比较四个数字的大小 代码

在textbox1、2、3、4中输入四个数字,然后在textbox5中输出结果(用<=号连接,从小到大排列)... 在textbox1、2、3、4中输入四个数字,然后在textbox5中输出结果(用<=号连接,从小到大排列) 展开
 我来答
xtuiop4
2014-03-24 · TA获得超过219个赞
知道答主
回答量:152
采纳率:0%
帮助的人:54.6万
展开全部
用不到2个命令按钮 1个就够
在按钮的过程中写如下代码
dim x as long , y as long ,z as long ,j as long ,n as long
dim k as integer
x = val(text1.text)
y = val(text2.text)
z = val(text3.text)
j = val(text4.text)
if x = then k = k+1
if y= then k = k+1
if z= then k = k+1
if j= then k = k+1
' 若输入的数有负数 则必须先在这里写下 n=-.....()
do
if x <>0 and n = x then
text5.text = text5.text &" " & x
k = k +1
end if
if y <>0 and n = then
text5.text = text5.text &" " & y
k = k +1
end if
if z <>0 and n = z then
text5.text = text5.text &" " & z
k = k +1
end if
if j <>0 and n = j then
text5.text = text.text &" " & j
k = k +1
end if
if k = 4 then exit for
n=n+1
loop

这是VB的代码。。。。 不知道.net 适用不
aqua6573
2014-04-02
知道答主
回答量:9
采纳率:0%
帮助的人:4万
展开全部
Function Test(ByVal i1 As Double, ByVal i2 As Double, ByVal i3 As Double, ByVal i4 As Double) As String
Dim nList As New List(Of Double)
nList.Add(i1)
nList.Add(i2)
nList.Add(i3)
nList.Add(i4)
Dim l = From item In nList Order By item
Dim s As String
Dim isFirst As Boolean = True
For Each i In l
If isFirst Then
isFirst = False
s = i
Else
s = s & "<= " & i
End If
Next
Return s
End Function
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式