Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


InStr / Right function

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,59159
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> InStr / Right function
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 InStr / Right function - 4/15/2008 11:47:46 PM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
Hi Guys, I'm kind of new to programming and have a question about an asp page that uses vbscript that I need to alter.

What happens now is   I have a user upoad a file, my program looks for certain things using InStr, for example If Instr(1, strline, "Label="), it then copies the next line to a numbered line in a destination file. 

Now I have a new set of files being uploaded that aren't as uniformly formatted as above.  So I need to look for ":" in a string, which could be at any position and copy everything after the colon to the numbered line.  I am unsure how to approah this and could use any advice that could point me in the right direction.

Thanks
 
 
Post #: 1
 
 RE: InStr / Right function - 4/16/2008 12:48:57 AM   
  ebgreen


Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
There are a couple of ways to do this. The way I would do it is this:

'strLine is the line you want to look for the data in
If InStr(strLine, ":") Then
   strData = Split(strLine, ":")(1)
End If

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to alpizzle)
 
 
Post #: 2
 
 RE: InStr / Right function - 4/16/2008 1:08:39 AM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
wow, thanks ebgreen, I was making that waaaay more dificult than it needed to be.  I appreciate the help

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: InStr / Right function - 4/16/2008 2:19:29 AM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
Sorry to ask but one more question if you could help.  It appears way down the file there are some lines that have multiple colons on each line, any tips on that?

I am using the code as you suggested and it's fantastic for 99% of the lines

If InStr(strLine, ":") Then

strData = Split(strLine, ":")(1)
streamDestFile.WriteLine phNumber & " " & strData
phNumber = phNumber + 1

End If

(in reply to alpizzle)
 
 
Post #: 4
 
 RE: InStr / Right function - 4/16/2008 2:55:01 AM   
  ebgreen


Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
Could you show some of the problematic lines?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to alpizzle)
 
 
Post #: 5
 
 RE: InStr / Right function - 4/16/2008 3:10:34 AM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
Sure thing, here are a couple of examples:

CHANNEL_READING_STATS:%d readings on Chan %d: Avg: %s  Min: %d  Max:  %d  Alt: Avg: %s  Min: %d  Max %d


FSC_NEXT_LOOP_6_STR5:    Note:  Lateral channel tare replaces offset in normal operation.

Basically I need everything left of the first colon removed, which would write line numbers and the remainder of the string to the destination file. Like the following:

1 Note:  Lateral channel tare replaces offset in normal operation.

Thanks ebgreen

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: InStr / Right function - 4/16/2008 3:16:21 AM   
  ebgreen


Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
Oh, so would this statement apply to all lines?

"If a colon is present then the data of interest is everything after the first colon"

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to alpizzle)
 
 
Post #: 7
 
 RE: InStr / Right function - 4/16/2008 3:19:15 AM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
that's correct.

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: InStr / Right function - 4/16/2008 3:40:56 AM   
  ebgreen


Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
Remeber that "There are a couple of ways..." statement? Well we are going to go a different way


'strLine is the line you want to look for the data in
strData = Mid(strLine, InStr(strLine, ":")+1)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to alpizzle)
 
 
Post #: 9
 
 RE: InStr / Right function - 4/16/2008 4:55:52 AM   
  alpizzle

 

Posts: 6
Score: 0
Joined: 4/15/2008
Status: offline
Thanks so much for the help ebgreen, I really appreciate it, that worked very well. 

(in reply to ebgreen)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> InStr / Right function Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts