Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: parse Int


Message #1 by Roger Balliger <Roger@i...> on Wed, 25 Jul 2001 11:20:20 -0700
Does anyone know of a code snippet that will parse variable length integers

from a string.



Example:

stringA = 12b

stringB = 1a



The code must:

1) determine the length of the integer to be extracted and 

2) extract the integer



new values:

varA = 12

varB = 1



Need more info? Let me know.  Thanks.

Roger







Message #2 by "Owen Mortensen" <ojm@a...> on Wed, 25 Jul 2001 12:00:38 -0700
Wouldn't this work?



varA = CInt(stringA)

varB = CInt(stringB)

?

Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 11:20 AM

To: ASP Web HowTo

Subject: [asp_web_howto] parse Int





Does anyone know of a code snippet that will parse variable length integers

from a string.



Example:

stringA = 12b

stringB = 1a



The code must:

1) determine the length of the integer to be extracted and

2) extract the integer



new values:

varA = 12

varB = 1



Need more info? Let me know.  Thanks.

Roger



Message #3 by Roger Balliger <Roger@i...> on Wed, 25 Jul 2001 12:51:15 -0700
No.  It gives a Type Mismatch error because text cant become a number.



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 12:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Wouldn't this work?



varA =3D CInt(stringA)

varB =3D CInt(stringB)

?

Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 11:20 AM

To: ASP Web HowTo

Subject: [asp_web_howto] parse Int





Does anyone know of a code snippet that will parse variable length 

integers

from a string.



Example:

stringA =3D 12b

stringB =3D 1a



The code must:

1) determine the length of the integer to be extracted and

2) extract the integer



new values:

varA =3D 12

varB =3D 1



Need more info? Let me know.  Thanks.

Roger



Message #4 by "Johnson, Israel" <IJohnson@R...> on Wed, 25 Jul 2001 15:55:04 -0400
String A & B contains text...  I don't think parseInt or CInt will 

convert

anything with text. 



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 3:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





No.  It gives a Type Mismatch error because text cant become a number.



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 12:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Wouldn't this work?



varA =3D CInt(stringA)

varB =3D CInt(stringB)

?

Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 11:20 AM

To: ASP Web HowTo

Subject: [asp_web_howto] parse Int





Does anyone know of a code snippet that will parse variable length 

integers

from a string.



Example:

stringA =3D 12b

stringB =3D 1a



The code must:

1) determine the length of the integer to be extracted and

2) extract the integer



new values:

varA =3D 12

varB =3D 1



Need more info? Let me know.  Thanks.

Roger



Message #5 by "Owen Mortensen" <ojm@a...> on Wed, 25 Jul 2001 13:18:52 -0700
Looks like Microsoft, in their infinite wisdom, chose to leave the "Val"

function out of VBScript/ASP!  Looks like you might have to write your own

val function....



Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





No.  It gives a Type Mismatch error because text cant become a number.



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 12:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Wouldn't this work?



varA =3D CInt(stringA)

varB =3D CInt(stringB)

?

Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 11:20 AM

To: ASP Web HowTo

Subject: [asp_web_howto] parse Int





Does anyone know of a code snippet that will parse variable length 

integers

from a string.



Example:

stringA =3D 12b

stringB =3D 1a



The code must:

1) determine the length of the integer to be extracted and

2) extract the integer



new values:

varA =3D 12

varB =3D 1



Need more info? Let me know.  Thanks.

Roger



Message #6 by Roger Balliger <Roger@i...> on Wed, 25 Jul 2001 13:37:00 -0700
Yup.  I'll likely have to grab the first to chars of the string and 

test

against a numerical value then if false, trim it again.  That should 

give me

what I want.



Thanks.

Roger



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 1:19 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Looks like Microsoft, in their infinite wisdom, chose to leave the 

"Val"

function out of VBScript/ASP!  Looks like you might have to write your 

own

val function....



Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





No.  It gives a Type Mismatch error because text cant become a number.



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 12:01 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Wouldn't this work?



varA =3D3D CInt(stringA)

varB =3D3D CInt(stringB)

?

Owen



Message #7 by "Owen Mortensen" <ojm@a...> on Wed, 25 Jul 2001 14:04:48 -0700
If you can depend on the fact that the string will never have leading

spaces, you can just get the index of the first non-numeric and then use it

in a left() function to get the number.  VB is starting to sound a lot like

perl: more than one way to do something....



Owen



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: Wednesday, July 25, 2001 1:37 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Yup.  I'll likely have to grab the first to chars of the string and 

test

against a numerical value then if false, trim it again.  That should 

give me

what I want.



Thanks.

Roger



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, July 25, 2001 1:19 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: parse Int





Looks like Microsoft, in their infinite wisdom, chose to leave the 

"Val"

function out of VBScript/ASP!  Looks like you might have to write your 

own

val function....



Owen



Message #8 by "Ken Schaefer" <ken@a...> on Thu, 26 Jul 2001 12:52:23 +1000
RegEx? Replace all alpha chars with ""



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Roger Balliger" <Roger@i...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, July 26, 2001 4:20 AM

Subject: [asp_web_howto] parse Int





: Does anyone know of a code snippet that will parse variable length

integers

: from a string.

:

: Example:

: stringA = 12b

: stringB = 1a

:

: The code must:

: 1) determine the length of the integer to be extracted and

: 2) extract the integer

:

: new values:

: varA = 12

: varB = 1

:

: Need more info? Let me know.  Thanks.

: Roger





Message #9 by Roger Balliger <Roger@i...> on Thu, 26 Jul 2001 12:04:52 -0700
Ken,



I appreciate the suggestion to use RegExp to parse integers and it 

probably

works great.  However, my company is using IIS 4.0 and the RegExp 

doesn't

seem to work with it.



Thanks.

Roger



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, July 25, 2001 7:52 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: parse Int





RegEx? Replace all alpha chars with ""



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Roger Balliger" <Roger@i...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, July 26, 2001 4:20 AM

Subject: [asp_web_howto] parse Int





: Does anyone know of a code snippet that will parse variable length

integers

: from a string.

:

: Example:

: stringA =3D 12b

: stringB =3D 1a

:

: The code must:

: 1) determine the length of the integer to be extracted and

: 2) extract the integer

:

: new values:

: varA =3D 12

: varB =3D 1

:

: Need more info? Let me know.  Thanks.

: Roger

Message #10 by Roger Balliger <Roger@i...> on Thu, 26 Jul 2001 12:31:22 -0700
My apologies.  There was pilot error on my part.  The RegExp object 

does, in

fact, work with IIS 4.0.



Roger



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, July 25, 2001 7:52 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: parse Int





RegEx? Replace all alpha chars with ""



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Roger Balliger" <Roger@i...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, July 26, 2001 4:20 AM

Subject: [asp_web_howto] parse Int





: Does anyone know of a code snippet that will parse variable length

integers

: from a string.

:

: Example:

: stringA =3D 12b

: stringB =3D 1a

:

: The code must:

: 1) determine the length of the integer to be extracted and

: 2) extract the integer

:

: new values:

: varA =3D 12

: varB =3D 1

:

: Need more info? Let me know.  Thanks.

: Roger

Message #11 by "Vince Kavanagh" <vince@6...> on Thu, 26 Jul 2001 23:07:38 +0100
How about adapting this?



<%@ Language=VBScript %>

<%

Function ExtractCharNum()

Dim strLen

Dim strCharOut

Dim i

Dim strTemp

Dim strNumOut



strIn = Request.Form("text1")



strLen = Len(strIn)

strOut = ""

For i = 1 To strLen



strTemp = Left(strIn, 1)

strIn = Right(strIn, strLen - i)



If (Asc(strTemp) >= 65 And Asc(strTemp) <= 90) Or (Asc(strTemp) >= 97 And

Asc(strTemp) <= 122) Then

strCharOut = strCharOut & strTemp

End If

If (Asc(strTemp) >= 48 And Asc(strTemp) <= 57) Then

strNumOut = strNumOut & strTemp

End If



Next

%>

<HTML>

<HEAD>

</HEAD>

<BODY>

<FORM name=charNum method=post action=charNum.asp>

<P><INPUT id=text1 name=text1> 

<INPUT id=text2 name=text2 value=<%=strCharOut%>><INPUT id=text3 name=text3

value=<%=strNumOut%>>

<INPUT id=submit1 name=submit1 type=submit value=Submit>

</P>

</FORM>



</BODY>

</HTML>

<%

End Function

%>

<%

	Call ExtractCharNum()

%>



Best Regards,



Vince.



-----Original Message-----

From: Roger Balliger [mailto:Roger@i...]

Sent: 26 July 2001 20:31

To: ASP Web HowTo

Subject: [asp_web_howto] Re: parse Int





My apologies.  There was pilot error on my part.  The RegExp object does, in

fact, work with IIS 4.0.



Roger



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, July 25, 2001 7:52 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: parse Int





RegEx? Replace all alpha chars with ""



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Roger Balliger" <Roger@i...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, July 26, 2001 4:20 AM

Subject: [asp_web_howto] parse Int





: Does anyone know of a code snippet that will parse variable length

integers

: from a string.

:

: Example:

: stringA = 12b

: stringB = 1a

:

: The code must:

: 1) determine the length of the integer to be extracted and

: 2) extract the integer

:

: new values:

: varA = 12

: varB = 1

:

: Need more info? Let me know.  Thanks.

: Roger
Message #12 by "TomMallard" <mallard@s...> on Thu, 26 Jul 2001 22:50:57 -0700
function returnIntegers(strInput)

    dim strArray(len(strInput))

    for i = 0 to ubound(strArray)

        if isnumeric(strArray(i)) then

            strOutput = strOutput & cstr(strArray(i))

        end if

    next

    returnIntegers = cint(strOutput)

end function



tom mallard

seattle

----- Original Message -----

From: "Roger Balliger" <Roger@i...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, July 26, 2001 12:04 PM

Subject: [asp_web_howto] Re: parse Int





> Ken,

>

> I appreciate the suggestion to use RegExp to parse integers and it

> probably

> works great.  However, my company is using IIS 4.0 and the RegExp

> doesn't

> seem to work with it.

>

> Thanks.

> Roger

>

> -----Original Message-----

> From: Ken Schaefer [mailto:ken@a...]

> Sent: Wednesday, July 25, 2001 7:52 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Re: parse Int

>

>

> RegEx? Replace all alpha chars with ""

>

> Cheers

> Ken

>

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> ----- Original Message -----

> From: "Roger Balliger" <Roger@i...>

> To: "ASP Web HowTo" <asp_web_howto@p...>

> Sent: Thursday, July 26, 2001 4:20 AM

> Subject: [asp_web_howto] parse Int

>

>

> : Does anyone know of a code snippet that will parse variable length

> integers

> : from a string.

> :

> : Example:

> : stringA = 12b

> : stringB = 1a

> :

> : The code must:

> : 1) determine the length of the integer to be extracted and

> : 2) extract the integer

> :

> : new values:

> : varA = 12

> : varB = 1

> :

> : Need more info? Let me know.  Thanks.

> : Roger

>



Message #13 by "THX 1138" <vss@5...> on Fri, 27 Jul 2001 02:52:23 -0500
here is a function i wrote so VBS can use regexp:



<SCRIPT LANGUAGE=JAVASCRIPT RUNAT=SERVER>

function VBReplace(strString,strSearch,strReplace) {

    // strSearch is the Regular Expression Pattern,strReplace replaces the

search string, strString is the string to search

    // example:  MyString = dbi_replace(MyString,"/\s*,\s*/g",",")

    // escape double qoutes in the strSearch when calling from VBScript -

replace /"/ with /""/

    strSearch = eval(strSearch)

    strReplace = (String(strReplace)=="undefined") ? "" : String(strReplace)

    strString = strString.replace(strSearch,strReplace)

    return strString

}

</SCRIPT>



THX1138



"Ken Schaefer" <ken@a...> wrote in message

news:86980@a..._web_howto...

>

> RegEx? Replace all alpha chars with ""

>

> Cheers

> Ken

>

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> ----- Original Message -----

> From: "Roger Balliger" <Roger@i...>

> To: "ASP Web HowTo" <asp_web_howto@p...>

> Sent: Thursday, July 26, 2001 4:20 AM

> Subject: [asp_web_howto] parse Int

>

>

> : Does anyone know of a code snippet that will parse variable length

> integers

> : from a string.

> :

> : Example:

> : stringA = 12b

> : stringB = 1a

> :

> : The code must:

> : 1) determine the length of the integer to be extracted and

> : 2) extract the integer

> :

> : new values:

> : varA = 12

> : varB = 1

> :

> : Need more info? Let me know.  Thanks.

> : Roger

>

>

>

>






  Return to Index