VB 分割字符串
5个回答
展开全部
strName As String, ParamArray intScores() As Variant)
Dim intI,k As Integer
Dim substr as String
k=0
substr=""
Debug.Print strName; " Scores"
' 用 UBound 函数决定数组的上限。
For intI = 0 To UBound(intScores())
Debug.Print " "; intScores(intI)
substr=substr+intScores(intI)
k=k+1
IF(k=2) then
Debug.Pring " "; substr
k=0
substr=""
End If
Next intI
End Sub
Dim intI,k As Integer
Dim substr as String
k=0
substr=""
Debug.Print strName; " Scores"
' 用 UBound 函数决定数组的上限。
For intI = 0 To UBound(intScores())
Debug.Print " "; intScores(intI)
substr=substr+intScores(intI)
k=k+1
IF(k=2) then
Debug.Pring " "; substr
k=0
substr=""
End If
Next intI
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jinfahua是正解,结贴吧
附上方法2:
用到split函数
Private Sub Command1_Click()
Dim s As String, c1 As String, c2 As String
Dim i As Integer
s = "ABC DEF H"
a = Split(s)
c1 = a(0)
For i = 1 To UBound(a)
c2 = c2 & " " & a(i)
Next
c2 = Trim(c2)
Print c1
Print c2
End Sub
附上方法2:
用到split函数
Private Sub Command1_Click()
Dim s As String, c1 As String, c2 As String
Dim i As Integer
s = "ABC DEF H"
a = Split(s)
c1 = a(0)
For i = 1 To UBound(a)
c2 = c2 & " " & a(i)
Next
c2 = Trim(c2)
Print c1
Print c2
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-02-27
展开全部
没有容错 处理
Private Sub SplitFunc(Dim inString As String,Dim outStr1 As String,Dim outStr2 As string)
Dim Length
Length=InStr(inString," ")
outStr1=Left(inString,Length-1)
outStr2=Right(inString,Len(inString)-Length)
End Sub
Dim str1,str2 As String
SplitFunc "abc def h",str1,str2
MsgBox "Part1: " & str1 & vbNewLine & "Part2: " & str2,,"SplitFunc"
Private Sub SplitFunc(Dim inString As String,Dim outStr1 As String,Dim outStr2 As string)
Dim Length
Length=InStr(inString," ")
outStr1=Left(inString,Length-1)
outStr2=Right(inString,Len(inString)-Length)
End Sub
Dim str1,str2 As String
SplitFunc "abc def h",str1,str2
MsgBox "Part1: " & str1 & vbNewLine & "Part2: " & str2,,"SplitFunc"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim S As String, C1 As String, C2 As String
Dim I As Integer
S = "ABC DEF H"
I = InStr(1, S, " ")
C1 = Left(S, I - 1)
C2 = Mid(S, I + 1)
Dim I As Integer
S = "ABC DEF H"
I = InStr(1, S, " ")
C1 = Left(S, I - 1)
C2 = Mid(S, I + 1)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询