Gruppe
Allgemein
Problem
Wie kann ich in eine InputBox eingegebene Daten in Variablen aufteilen? Als Trennzeichen ist ein Semikolon vorgesehen.
StandardModule: basMain
Sub Aufteilen()
Dim col As New Collection
Dim iCounter As Integer
Dim sTxt As String, sPart As String
sTxt = InputBox( _
prompt:="Zeichenfolge:" & vbLf & _
"(Semikoli als Feldtrenner)", _
Default:="ab;cd;ef;gh")
Do
col.Add Left(sTxt, InStr(sTxt, ";") - 1)
sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, ";"))
If InStr(sTxt, ";") = False Then
col.Add sTxt
Exit Do
End If
Loop
For iCounter = 1 To col.Count
MsgBox col(iCounter)
Next iCounter
End Sub