vb取字符串中最大值

来源:百度知道 编辑:UC知道 时间:2024/06/08 00:26:02
,1500,1200,1800,1020
请高手帮忙。

小题大做,解决这么简单的问题还需要冒泡吗?

Private Sub Command1_Click()
Dim s As String, a, max As Long
s = "1500,1200,1800,1020"
a = Split(s, ",")
max = a(0)
For i = 1 To UBound(a)
If a(i) > max Then max = a(i)
Next
'结果在max中
End Sub

dim str,max,stra,i,j

str="1500,1200,1800,1020"
stra=split(str,",")
max=stra(0)
for i=0 to ubound(stra)
if(stra(i)>max) then
max=stra(i)
end if
next
msgbox(max)