用VB实现如下功能怎样实现
比如:textbox的文本内容为下面数字011,1
202,2
033,3
452,4
..........
(行数不确定)
经过VB运行后,textbox的文本内容为下面形式
11 ,1
202,2
33 ,3
452,4
..........
(行数不确定)
我是这样用的:
Private Sub changedate_Click()
Dim temp, a
temp = Split(Text1.Text, Chr$(10))
Dim i As Long
For i = LBound(temp) To UBound(temp)
Dim b, c
If Left(temp(i), 1) = "0" Then
b = Right(temp(i), Len(temp(i)) - 1)
c = Split(b, ",")
a = c(0) & Space(1) & "," & c(1)
Else
a = temp(i)
End If
Text1.Text = a
Next i
但是这样最后在Text1里显示是最后一个a的值,原因在于,Next i后,后面a的值覆盖掉了前面a的值,有什么办法能让每个a的逐条在文本框Text1中分行显示?问题补充:
--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- Dim strLine() As String, strItem() As String, strText As String
Dim i As Long
strLine = Split(Text1, vbCrLf)
For i = 0 To UBound(strLine)
strItem = Split(strLine(i), ",")
If UBound(strItem) = 1 And IsNumeric(strItem(0)) Then
strLine(i) = Val(strItem(0)) & "," & strItem(1)
End If
strText = strText & IIf(strText > "", vbCrLf, "") & strLine(i)
Next i
Text1 = strText
补充:VB , 基础类