vb中split函数实例
答案:1 悬赏:80 手机版
解决时间 2021-02-24 22:07
- 提问者网友:风月客
- 2021-02-24 16:01
vb中split函数实例
最佳答案
- 五星知识达人网友:鸠书
- 2021-02-24 17:39
Dim str As String = "", temp, n As Integer
Dim str1 As String = "12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim a() As String = Split(str1, ",")
For i = 1 To UBound(a) Step 1
a(i) = Val(a(i))
Next
temp = 0
n = 0
For i = 1 To UBound(a)
If a(i) > temp Then
temp = a(i)
End If
If a(i) > 0 Then
n = n + 1
End If
Next
str = str & "正数的个数为 " & n
str = str & "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str & i & " "
End If
Next
TextBox6.Text = str
Dim str1 As String = "12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim a() As String = Split(str1, ",")
For i = 1 To UBound(a) Step 1
a(i) = Val(a(i))
Next
temp = 0
n = 0
For i = 1 To UBound(a)
If a(i) > temp Then
temp = a(i)
End If
If a(i) > 0 Then
n = n + 1
End If
Next
str = str & "正数的个数为 " & n
str = str & "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str & i & " "
End If
Next
TextBox6.Text = str
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯