Extracting certain parts of a text from a string...

defiance

Member
Joined
May 8, 2011
Messages
13
Programming Experience
Beginner
for the helpful dudes to help me again.. ;p

what is the command line to single out certain parts of text from a string only..
for example..

string = "Hellodullardtomboy"

what is the command to capture only the word "DULL" between "hello" and "ardtomboy" only.
thanz in advance.. :)
 
You're going to have to be much clearer about what you mean. What do you mean by "capture"? Do you mean determine whether a specific substring exists in another string? What index it's at? There are various other interpretations too. You need to provide a FULL and CLEAR description of exactly what you're trying to achieve. Examples can be useful but a single example without a description of the general case is fairly useless.
 
i remember in VB6 where I did something similar to what I am asking now..

gathering only certain characters from a string and putting it to a different string..
actually what I needed is the command to just single out what i needed.
as example above..

maybe from string1 = "hellodullardboy"

i vb-ed some command to only gather the dull from between hello and ardboy
and putting it to maybe string2..

i just wanted to refresh myself on what that command is, and whether it is still
the same as in vb6 or not.. but most likely.. is not the same..

ok, just recall something of that command, may be something like this..

string1.text = "hellodullardboy"
string2.text = <Forgotten Command here>(6,4)

and string2.text should return as "dull"

the number 6 and 4 should be starting point and number of words onwards..
or something like that.. at least thats what I think was how it went in vb6
 
Last edited:
Substring is what you're after - String.Substring Method

And in context of your example (remember the position is zero based) :

VB.NET:
Dim string1 as String
Dim string2 as String

string1 = "hellodullardboy"
string2 = string1.Substring(5,4)

You could also tie that up with an indexof String.Indexof Method to test if the characters you're searching for actually exist in the source string and where.

Hope that helps.
 
thanz for the guidance, Menthos..

i'll give it a try later and will post if anything happens..
like my pop corns catching on fire.. lol
 
Back
Top