Split bi commas
Hi,
There are a way to separate the string by commas?
Please Help.
Best Regards
Naruse
Junior Poster in Training
53 posts since Jan 2008
Reputation Points: 34
Solved Threads: 0
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
You right sir, it works perfect with split function.
This what i am doing with split function :
Private Sub Command1_Click()
Dim temp As Variant
Dim str As String
str = "i,love,you,forever"
temp = Split(str, ",")
MsgBox temp(0) + vbCrLf + temp(1) + vbCrLf + temp(2) + vbCrLf + temp(3)
End Sub
Naruse
Junior Poster in Training
53 posts since Jan 2008
Reputation Points: 34
Solved Threads: 0
MsgBox temp(0) + vbCrLf + temp(1) + vbCrLf + temp(2) + vbCrLf + temp(3)
You accessing array with this way..
How about if you have many words separated with commas?
Are you want to get all data by write it one by one?
Use looping and Ubound to get last index of array
Private Sub Command1_Click()
Dim temp As Variant
Dim str As String
Dim arr As String
str = "i,love,you,forever"
temp = Split(str, ",")
For i = 0 To UBound(temp) ' get the last index with Ubound
arr = arr + temp(i) + vbCrLf ' Read data until last index and store it on arr
Next i
MsgBox arr ' display it on message box
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
Wow, it's great sir.
Thank you for sharing sir. You enlighten me so much..
Naruse
Junior Poster in Training
53 posts since Jan 2008
Reputation Points: 34
Solved Threads: 0
You're Welcome.
Happy Coding :)
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444