私はこれを書きました。はい、私はそれがVB6であることを知っています。はい、それは製品コードであり、goto を使用していることはわかっています。私は怠け者で邪悪な獣です...
だから私に(そして私たちの残りの人たちに)それがどのように書かれるべきかを見せてください
Public Function SplitString(ByVal sText As Variant) As Variant
Dim nHere As Long
Dim cHere As String * 1
Dim aRes As Variant
Dim nRes As Long
Dim bInquote As Boolean
Dim sString As String
ReDim aRes(0)
nHere = 1
nRes = 0
Do
If nHere > Len(sText) Then Exit Do
cHere = Mid$(sText, nHere, 1)
If cHere = Chr$(32) Then
If bInquote Then
sString = sString & cHere
GoTo nextChar
End If
If sString <> vbNullString Then
aRes(nRes) = sString
sString = vbNullString
nRes = nRes + 1
ReDim Preserve aRes(nRes)
End If
GoTo nextChar
ElseIf cHere = Chr$(34) Then
bInquote = Not bInquote
GoTo nextChar
Else
sString = sString & cHere
End If
nextChar:
nHere = nHere + 1
Loop
If sString <> vbNullString Then
aRes(nRes) = sString
End If
SplitString = aRes
End Function
ちなみに、これは文字列を配列に分割します。文字列内の要素は引用符で囲むことができます。