VB中文本框中内容写入数组中 20
文本框中有一组数字31,2,45,10,124,74,……i文本框中数字的个数少于20组,且每两个数字之间用逗号加空格隔开。设计一个程序,读取文本框中的每一个数字,并按顺...
文本框中有一组数字 31,2,45,10,124,74,……i
文本框中数字的个数少于20组,且每两个数字之间用逗号加空格隔开。
设计一个程序,读取文本框中的每一个数字,并按顺序放入数组A(i)中,使得A(1)=31,A(2)=2,A(3)=45……A(i)=i 展开
文本框中数字的个数少于20组,且每两个数字之间用逗号加空格隔开。
设计一个程序,读取文本框中的每一个数字,并按顺序放入数组A(i)中,使得A(1)=31,A(2)=2,A(3)=45……A(i)=i 展开
4个回答
展开全部
Private Sub Form_Click()
ReDim a(Len(Text1.Text)) As Long
Dim b%, c%
b = 0
For i = 1 To Len(Text1.Text)
b = b + 1
If i = Len(Text1.Text) Then
a(c + 1) = Mid(Text1.Text, i - b + 1, b)
Print a(c + 1)
End If
If Mid(Text1.Text, i, 1) = "," Then
c = c + 1
a(c) = Mid(Text1.Text, i + 1 - b, b)
b = 0
Print a(c)
End If
Next
End Sub
ReDim a(Len(Text1.Text)) As Long
Dim b%, c%
b = 0
For i = 1 To Len(Text1.Text)
b = b + 1
If i = Len(Text1.Text) Then
a(c + 1) = Mid(Text1.Text, i - b + 1, b)
Print a(c + 1)
End If
If Mid(Text1.Text, i, 1) = "," Then
c = c + 1
a(c) = Mid(Text1.Text, i + 1 - b, b)
b = 0
Print a(c)
End If
Next
End Sub
展开全部
Private Sub Command1_Click()
Dim n
Dim a(1 To 5)
n = Split(Text1.Text, ",")
On Error Resume Next
Print "a(1) =" & n(0)
Print "a(2) =" & n(1)
Print "a(3) =" & n(2)
Print "a(4) =" & n(3)
Print "a(5) =" & n(4)
或
Private Sub Command1_Click()
Dim a(), i As Integer
a = Split(Text1.Text, ", ")
ReDim Preserve a(UBound(a) + 1)
For i = 1 To UBound(a)
a(i) = a(i - 1)
Next
End Sub
End Sub
Dim n
Dim a(1 To 5)
n = Split(Text1.Text, ",")
On Error Resume Next
Print "a(1) =" & n(0)
Print "a(2) =" & n(1)
Print "a(3) =" & n(2)
Print "a(4) =" & n(3)
Print "a(5) =" & n(4)
或
Private Sub Command1_Click()
Dim a(), i As Integer
a = Split(Text1.Text, ", ")
ReDim Preserve a(UBound(a) + 1)
For i = 1 To UBound(a)
a(i) = a(i - 1)
Next
End Sub
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a(), i As Integer
a = Split(Text1.Text, ", ")
ReDim Preserve a(UBound(a) + 1)
For i = 1 To UBound(a)
a(i) = a(i - 1)
Next
End Sub
Dim a(), i As Integer
a = Split(Text1.Text, ", ")
ReDim Preserve a(UBound(a) + 1)
For i = 1 To UBound(a)
a(i) = a(i - 1)
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
分隔符$=","
A=split( text1.text, 分隔符$ )
A=split( text1.text, 分隔符$ )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询