Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extracting word from line without knowing the value of it

Status
Not open for further replies.

newbie1983

Programmer
Sep 9, 2003
52
GB
hi id like to extract a word from the line only knowing its positiong for example 20 from the left, but only that word and no other words preceeding it. Any ideas?

An example of a line that i am reading in is below:

i would like to extract the word which is currently 'RUNNING' but this can vary which is why i want to extract it from its position only.

HLWSALACE002 Administrator Checking RUNNING

Kind Regards,

Hinesh
 

??? 0 out of 11 ??? and you only have 6 replies to the 11 threads that you have started???

Please Read FAQ222-2244

Now for a little more clarification on what you are asking...

The word RUNNING is the 11th word and not the 20th but I am going to guess that the word you are looking for either starts at the 20th position or has characters at the 20th position in which case the word you would be looking for is extract in your sentance and to be more precise it is the "r" that is at the 20th position.

So if the word that you are looking for has its first character at the nth position and in the case of your sentance example the nth posion equals 54 then (for this example we will use 53 to get the single ticks also) ...

[tt]
Dim S As String
Dim NextSpace As Integer

S = "i would like to extract the word which is currently 'RUNNING' but this can vary which is why i want to extract it from its position only."
NextSpace = InStr(53, S, " ")
Debug.Print Mid(S, 53, (NextSpace - 53))
[/tt]

Once again Please Read FAQ222-2244

Good Luck

 
Hi vb5prgrmr, thanks for the code but it doesnt seem to work but its a start

Kind regards,

Hinesh
 

Did you check your debug window for the output???

If so then what is wrong with the example, meaning what did you get on output because I recieved 'RUNNING'!!!

Have you read the FAQ22-2244 ???

 
oh yeh i got it working , just had to tweak ur code a lil.

Nah i havent, dont think i need to :p

Kind regards,

Hinesh
 

I really think you do need to read the FAQ222-2244. I think you will find it very informative. And what tweaks did you have to do???

 
HineshP
Try reading the faq referred - it will at least show you how to properly acknowledge replies given to your questions - it may even help you to get future questions answered!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top