vb题:在一个文本框中输入十个数字,用逗号隔开,单击“确定”按钮后将这些数字保存到数组中,并找出最大
展开全部
Private Sub Command1_Click()
Dim a, b, i
a = Split(Text1.Text, ",")
For i = 0 To UBound(a)
If b < Val(a(i)) Then b = a(i)
Next
MsgBox "最大值=" & b
End Sub
Dim a, b, i
a = Split(Text1.Text, ",")
For i = 0 To UBound(a)
If b < Val(a(i)) Then b = a(i)
Next
MsgBox "最大值=" & b
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim s() As Integer
Dim n As Integer
Dim i As Integer
Dim max As Integer
While (InStr(Text1.Text, ",") > 0)
n = n + 1
ReDim s(n) As Integer
s(n) = Left(Text1.Text, InStr(Text1.Text, ","))
Text1.Text = Mid(Text1.Text, InStr(Text1.Text, ",") + 1)
Wend
If n = 0 Then
ReDim s(1) As Integer
End If
s(0) = Text1.Text
For i = 0 To n
If max < s(i) Then
max = s(i)
End If
Next
MsgBox max
Dim n As Integer
Dim i As Integer
Dim max As Integer
While (InStr(Text1.Text, ",") > 0)
n = n + 1
ReDim s(n) As Integer
s(n) = Left(Text1.Text, InStr(Text1.Text, ","))
Text1.Text = Mid(Text1.Text, InStr(Text1.Text, ",") + 1)
Wend
If n = 0 Then
ReDim s(1) As Integer
End If
s(0) = Text1.Text
For i = 0 To n
If max < s(i) Then
max = s(i)
End If
Next
MsgBox max
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你一个思路:将字符串用split函数分解成数组,然后用冒泡法对数组排序。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有没有分割文本,再赋值,用FOR 循环,没电脑,不好写得
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询