By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,097 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,097 IT Pros & Developers. It's quick & easy.

extracting substrings in VB6

P: 2
Hi all,

I am new to this forum as well as Visual Basic. I haven't been able to find a resource that tells me what functions are available in Visual Basic like you can find the listing in C++ and java. If someone can tell me how to get that it would be great.

My question though is, I have a string variable in my VB code that has a long string (a combination of smaller strings seperated by ";") I need to extract all theses substrings. They can have variable lengths, so the extraction criteria is the seperator which is the semicolon.
Can someone please tell me how to do this. Do I have a built in function to do that which I think there should be one. or do I have to code it.

Thank you
Apr 3 '07 #1
Share this Question
Share on Google+
4 Replies


iburyak
Expert 100+
P: 1,017
Use Split function which has a delimiter parameter.
This function returns an array of values which is easy to loop through.


Try this little example:

[PHP]Dim sString As String
Dim arrString
Dim i As Integer

sString = "aaaa;bbb;ccccc;ddd"

arrString = Split(sString, ";")

For i = 0 To UBound(arrString)
Debug.Print arrString(i)
Next[/PHP]

Hope it helps.
Good Luck.
Apr 3 '07 #2

P: 2
Thank you very much, it did
Apr 3 '07 #3

Expert 5K+
P: 8,434
Thank you very much, it did
You need to watch out if it's possible (even if unlikely) that the data may contain a ";" within one of the fields.
Apr 3 '07 #4

100+
P: 149
Hi all,

I am new to this forum as well as Visual Basic. I haven't been able to find a resource that tells me what functions are available in Visual Basic like you can find the listing in C++ and java. If someone can tell me how to get that it would be great.

My question though is, I have a string variable in my VB code that has a long string (a combination of smaller strings seperated by ";") I need to extract all theses substrings. They can have variable lengths, so the extraction criteria is the seperator which is the semicolon.
Can someone please tell me how to do this. Do I have a built in function to do that which I think there should be one. or do I have to code it.

Thank you
Hi ,
I came across this good site that talks about handling strings in VB.

http://www.aivosto.com/vbtips/stringopt.html

You can have a look at this for future reference.

thanks
ansuman sahu
Apr 4 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.