Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: 14 Dec 2005 09:38:48 -0800,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


parse string into variables   
I want to create 3 test variables from this line:

***PRINTED=>12/14/2005*** Document 167, Book1 owned by USERNAME was
printed on im2020_PW_Admin via port IP_10.2.1.245.  Size in bytes:
410088; pages printed: 10

-username will be set to USERNAME
-size will be set to 4100088
-pages will be set to 10

I know I can do a series of InStr and Left and Right functions but I
just can wrap my head around it!

Help!  Thanks!

-mwm
date: 14 Dec 2005 09:38:48 -0800   author:   unknown

Re: parse string into variables   
mmethe@gmail.com wrote:
> I want to create 3 test variables from this line:
>
> ***PRINTED=>12/14/2005*** Document 167, Book1 owned by USERNAME was
> printed on im2020_PW_Admin via port IP_10.2.1.245.  Size in bytes:
> 410088; pages printed: 10
>
> -username will be set to USERNAME
> -size will be set to 4100088
> -pages will be set to 10
>
> I know I can do a series of InStr and Left and Right functions but I
> just can wrap my head around it!
>
> Help!  Thanks!
>
Here's a quick example
dim s, ar1, ar2, username
s="***PRINTED=>12/14/2005*** Document 167, " & _
"Book1 owned by USERNAME was printed on " &
"im2020_PW_Admin via port IP_10.2.1.245.  Size in bytes: " & _
"410088; pages printed: 10"
ar1=split(s,"owned by ")
ar2=split(ar(1)," was printed")
username=ar2(0)

HTH,
Bob Barrows

-- 
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
date: Wed, 14 Dec 2005 13:41:20 -0500   author:   Bob Barrows [MVP] com

Re: parse string into variables   
wrote:

> I want to create 3 test variables from this line:
>
> ***PRINTED=>12/14/2005*** Document 167, Book1 owned by USERNAME was
> printed on im2020_PW_Admin via port IP_10.2.1.245.  Size in bytes:
> 410088; pages printed: 10
>
> -username will be set to USERNAME
> -size will be set to 4100088
> -pages will be set to 10
>
> I know I can do a series of InStr and Left and Right functions but I
> just can wrap my head around it!
>
> Help!  Thanks!

With New RegExp
   .Pattern = "^\*{3}PRINTED.* owned by (\w+) was printed on .*" _
            & "Size in bytes: (\d+); pages printed: (\d+)$"
   Set Matches = .Execute(line)
   If Matches.Count = 0 Then
     username = ""
     size = ""
     pages = ""
   Else
     username = Matches(0).Submatches(0)
     size = Matches(0).Submatches(1)
     pages = Matches(0).Submatches(2)
   End If
End With

-- 
Steve

If a man will begin with certainties, he shall end in doubts; but if he
will be content to begin with doubts, he shall end in certainties.
-Francis Bacon
date: Thu, 15 Dec 2005 08:42:43 -0500   author:   Steve Fulton

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us