473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extracting substrings in VB6

2 New Member
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 8803
iburyak
1,017 Recognized Expert Top Contributor
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(arrStrin g)
Debug.Print arrString(i)
Next[/PHP]

Hope it helps.
Good Luck.
Apr 3 '07 #2
ashilyas
2 New Member
Thank you very much, it did
Apr 3 '07 #3
Killer42
8,435 Recognized Expert Expert
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 New Member
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
11444
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 found exactly where the problem happens and wrote a simple interpolation filter that works like a charm... under DOS, using the old QuickBasic. I've used Perl for a while, but never to handle binary data, so I'm at a loss; and I really want to get...
7
14816
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 representing the integer into another std::string? In the example above, I'd want to end up with a std:string whose value is "243". The substrings "default(" and ")" are invariant - they're always present in the string I have to work with. ...
9
1807
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 have to search for in the data. I need to keep a count of how often each of these substrings occurs in my original data and then print it out at the end. This is a fairly mundane task, but since I have so many substrings, it's a pain having to...
3
2656
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 C:\testfile.txt or ... C:\download\temp\dlls\testfile.dll I want to be able to extract the file name from this textbox (and put it in a string) when I click a button. Can someone illustrate how to write this line of code?
5
6880
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
1734
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 for this so I used a Regex that splits the string at the first ³, ³ and again at the ³ (³. My problem is that I don¹t know how to extract the second member of the resulting array (FirstName) and assign it to another string. Using StringBuilder, as...
4
4182
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 substrings, 'FOO blah1a blah1b', 'FOO blah2', and 'FOO blah3a blah3b blah3b'. I've tried numerous variations on '.*(FOO((?!FOO).)*)+.*' and everything I've tried either matches too much or too little.
8
5052
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. Similarly, 'abcd' should give me , , , , , ,, , , , , , ,] I've tried the following but i cant prevent duplicates and i'm missing
2
2828
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? Given a *very* long string, A, and a shorter string, B, extract all substrings of A that differ from B in at most N positions. For example: N = 2 A = 'abcdefaacdefxbcxfaaabcdefaaaacdxf'
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9995
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.