Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim tempStr As String
- 'Dim tempVar As Variant
- 'tempstr = "gunawan~rini~faiz~rafi"
- 'tempvar = gwexplode(tempstr,"~")
- Dim tempvar(2)
- tempvar(0) = "gunawan"
- tempvar(1) = "faiz"
- tempvar(2) = "rafi"
- tempstr = gwimplode(tempvar,":")
- Dim t2var As Variant
- t2var = gwexplode(tempstr,":")
- Function gwImplode(v As Variant,sep As String) As String
- Dim s As String
- Dim i As Integer
- s=""
- For i=0 To UBound(v)
- If i = UBound(v) Then
- s = s + v(i)
- Else
- s = s + v(i) + sep
- End If
- Next
- gwImplode = s
- End Function
- Function gwexplode(textstr As String,sep As String) As Variant
- 'convert from string to variant
- 'gtw
- Dim temptextstr As String
- Dim tstr As String
- Dim t1 As string
- temptextstr = textstr
- If Right(temptextstr,1) <> sep Then
- temptextstr = temptextstr +sep+" "
- End If
- Dim tvar() As Variant
- Dim j As Integer, i As Integer
- j=-1
- i=0
- For i=1 To Len(temptextstr)
- If Mid(temptextstr,i,1) = sep Then
- j=j+1
- End If
- Next
- ReDim Preserve tvar(j)
- j=-1
- i=0
- tstr = temptextstr
- While tstr <> ""
- i=i+1
- t1 = Mid(tstr,i,1)
- If t1 = sep Then
- j=j+1
- tvar(j) = Trim(Mid(tstr,1,i-1))
- tstr = Right(tstr,Len(tstr)-Instr(tstr,sep))
- If tstr=" " Then tstr=""
- 'Msgbox tvar(j)
- i=0
- End If
- Wend
- gwexplode = tvar
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement