473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

extracting substrings in VB6

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
4 8775
iburyak
1,017 Expert 512MB
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
Thank you very much, it did
Apr 3 '07 #3
Killer42
8,435 Expert 8TB
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
ansumansahu
149 100+
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

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

Similar topics

1
by: Leandro Pardini | last post by:
Hello there, I'm trying to process a binary file and I really don't know how. The story: gPhoto2 downloads the images from my camera just fine, but small areas of 10x3 pixels are screwed up. I...
7
by: cpp_weenie | last post by:
Given a std::string of the form "default(N)" where N is an integer number of any length (e.g. the literal string might be "default(243)"), what is the quickest way to extract the characters...
9
by: C3 | last post by:
I have to process some data in C that is given to me as a char * array. I have a fairly large number of substrings (well, they're not actually printable, but let's treat them as strings) that I...
3
by: War Eagle | last post by:
I've been looking at .substring and .trim methods and I still have a question about extracting substrings from a textbox. Basically the textbox contains the full path to a file ... for example ...
5
by: ORC | last post by:
Is there an easy way to extract a number from a string like: result = ExtractNumber("this is a 4 string"); which should give the result = 4; Thanks Ole
3
by: Stephan Bour | last post by:
I have a string ³Name² in the following format: ³LastName, FirstName (Department)² that comes from Active Directory. I need to extract the FirstName from the string. Substrings are not practical...
4
by: Robert Dodier | last post by:
Hello all, I'm trying to find substrings that look like 'FOO blah blah blah' in a string. For example give 'blah FOO blah1a blah1b FOO blah2 FOO blah3a blah3b blah3b' I want to get three...
8
by: girish | last post by:
Hi, I want to generate all non-empty substrings of a string of length >=2. Also, each substring is to be paired with 'string - substring' part and vice versa. Thus, gives me , , , , , ] etc....
2
by: Pilcrow | last post by:
This problem was raised in comp.lang.perl.misc, and the poster was concerned, among other things, by the speed of execution. Since C is faster than perl, I wonder how a C coder would solve it? ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.