
VB.NET中,比较四个数字的大小 代码
在textbox1、2、3、4中输入四个数字,然后在textbox5中输出结果(用<=号连接,从小到大排列)...
在textbox1、2、3、4中输入四个数字,然后在textbox5中输出结果(用<=号连接,从小到大排列)
展开
2个回答
展开全部
用不到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 适用不
在按钮的过程中写如下代码
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 适用不
展开全部
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询