Hi,
There are a way to separate the string by commas?

Please Help.
Best Regards

Recommended Answers

All 5 Replies

use split function.

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
commented: Showing Good effort +13
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
commented: You enlighten me so much sir..Thank you :) +3
commented: good point. +2
commented: Good Point here.. :D +3

Wow, it's great sir.
Thank you for sharing sir. You enlighten me so much..

You're Welcome.
Happy Coding :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.