Re: How to return a sting of numbers from a longer string
- From: "Larry" <larry328NOSPAM@xxxxxxx>
- Date: Mon, 6 Nov 2006 21:19:59 -0500
First, I didn't tell you that this is a script being run in an htm file, so
I needed to change the msgbox into Alert.
Second, the code seems to require that I already know what whatimlookingfor
(EntryNum) is. But I don't. I'm trying to return this number. So the
question is, how can I look for a string (whatimlookingfor) within a string
(string) via the Instr statement, if I don't know what the smaller string
actually is, other than that it's a six digit number (which I think in all
cases will start with two zeros)?
Thanks,
"Franz aRTiglio" <franzgol@xxxxxxxxxxxx> wrote in message
news:454fcedc$0$13759$4fafbaef@xxxxxxxxxxxxxxxxxxxxxx
Larry wrote:http://www.website.com/cgi-bin/mt/mt.cgi?__mode=view&_type=entry&id=003322&blog_id=1
Let's say I have a string like this, which I'll call docAddress.
"http://www.website.com/cgi-bin/mt/mt.cgi?__mode=view&_type=entry&id=003322&
I want to return the six digit string inside it, which in this case is
003322, but it could be any six digit number, and I'll call it
EntryNum.
Dim string
Dim whatimlookingfor
Dim pointer
Dim x
string =
blog_id=1"
whatimlookingfor="id="
pointer = instr(string,whatimlookingfor)
If pointer= 0 then
msgbox (whatimlookingfor & " not found")
wscript.quit
End If
pointer = pointer + len(whatimlookingfor)
For x = pointer + 1 to len(string)
If isnumeric(mid(string,pointer,x-pointer))=false then exit for
next
If len(mid(string,pointer,x-pointer-1)) = 0 then
msgbox "numeric value not found"
Else
msgbox "Found !" & vbcrlf & mid(string,pointer,x-pointer-1)
End If
.
- Follow-Ups:
- References:
- How to return a sting of numbers from a longer string
- From: Larry
- Re: How to return a sting of numbers from a longer string
- From: Franz aRTiglio
- How to return a sting of numbers from a longer string
- Prev by Date: Re: How to return a sting of numbers from a longer string
- Next by Date: Re: Possible VB Error in Access 97 DB?
- Previous by thread: Re: How to return a sting of numbers from a longer string
- Next by thread: Re: How to return a sting of numbers from a longer string
- Index(es):
Relevant Pages
|