動的配列
'-----------------------------
' 動的配列
'-----------------------------
Dim mytxt1()
strType ="R"
If strType ="L" Then
strIn = "1,2,3,4,5"
'左から切り出し
Do
count = count + 1
ReDim Preserve mytxt1(count + 1) '動的に配列拡張
comma = InStr(strIn, ",")
If comma <> 0 Then mytxt1(count) = Left(strIn, comma - 1)
If comma <> 0 Then strIn = Mid(strIn, InStr(strIn, ",") + 1, _
Len(strIn) - InStr(strIn, ","))
If comma = 0 Then mytxt1(count) = strIn
If comma = 0 Then Exit Do
Loop
End If
If strType ="R" Then
strIn = "1,2,3,4,5"
' 右から切り出し
Do
count = count + 1
ReDim Preserve mytxt1(count + 1) '動的に配列拡張
mytxt1(count) = Right(strIn, Len(strIn) - InStrRev(strIn, ","))
strIn = Left(strIn, InStrRev(strIn, ",") - 1)
mytxt1(count + 1) = Right(strIn, Len(strIn) - InStrRev(strIn, ","))
If InStrRev(strIn, ",") = 0 Then Exit Do
Loop
End If
msgbox "mytxt1(1)=" & mytxt1(1) &vbCR &_
"mytxt1(2)=" & mytxt1(2) &vbCR &_
"mytxt1(3)=" & mytxt1(3) &vbCR &_
"mytxt1(4)=" & mytxt1(4) &vbCR &_
"mytxt1(5)=" & mytxt1(5)