String evaluation from right problem 
Author Message
 String evaluation from right problem

Can anyone give me some advice on how I can search for the first "\"
occurance from the right of a string like "D:\test\test.exe" in VBScript?
From that string I only want "test.exe" and not the entire path.

I have tried this code...

AttachTemp= (Request.QueryString("FAQAttachment"))
SlashPosition = InStr(AttachTemp,"\")
AttachVar = left(AttachVar,SlashPosition)

...but it returns "D:\" from the left?

Thanx in advance
MHarrison



Tue, 27 Jun 2000 03:00:00 GMT  
 String evaluation from right problem

Try:

SlashPos = InStrRev (SomeString, "\")
--
A.J. Fried


... Play League Pinball! ...



Quote:
> Can anyone give me some advice on how I can search for the first "\"
> occurance from the right of a string like "D:\test\test.exe" in vbscript?
> From that string I only want "test.exe" and not the entire path.

> I have tried this code...

> AttachTemp= (Request.QueryString("FAQAttachment"))
> SlashPosition = InStr(AttachTemp,"\")
> AttachVar = left(AttachVar,SlashPosition)

> ...but it returns "D:\" from the left?

> Thanx in advance
> MHarrison



Tue, 27 Jun 2000 03:00:00 GMT  
 String evaluation from right problem

Thanx...worked like a charm.



Tue, 27 Jun 2000 03:00:00 GMT  
 String evaluation from right problem

I spoke to soon...
I worked if the was only one subdirectory in the path...

d:\subdir1\test.exe retuned "test.exe"...

But if there is more than one subdir. than...

d:\subdir1\subdir2\test.exe returns "subdir2\test.exe"

Here is the code:

AttachTemp= (Request.QueryString("FAQAttachment"))
SlashPos = InStrRev (AttachTemp, "\")
AttachVar = right(AttachTemp,SlashPos)

Thanx in advance
MHarrison



Tue, 27 Jun 2000 03:00:00 GMT  
 String evaluation from right problem

Hi there,

Please read the documentation for the "Right" function again -- you are
confusing it with the Mid function.

The code that you want is

AttachVar = Mid(AttachTemp,SlashPos)

I hope that helps.

Eric

Quote:

>I spoke to soon...
>I worked if the was only one subdirectory in the path...

>d:\subdir1\test.exe retuned "test.exe"...

>But if there is more than one subdir. than...

>d:\subdir1\subdir2\test.exe returns "subdir2\test.exe"

>Here is the code:

>AttachTemp= (Request.QueryString("FAQAttachment"))
>SlashPos = InStrRev (AttachTemp, "\")
>AttachVar = right(AttachTemp,SlashPos)

>Thanx in advance
>MHarrison



Tue, 27 Jun 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. date string evaluation 20020923174942.914964-240

2. Q: Runtime evaluation of strings

3. Force Evaluation of String (Please Help)

4. A Baffling string manipulation problem - Right Function

5. evaluation problem

6. CheckBox Form Field Evaluation Problem

7. SQL Server 6.5 Evaluation Problem

8. Problems with boolean expression evaluation

9. Crystal Reports V9 Evaluation Problem

10. padding a string with spaces to the right

11. RegExp String-almost-right

12. getting right 2 characters from a string

 

 
Powered by phpBB® Forum Software