Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Parsing through data


Message #1 by JR Shortall <John.Shortall@e...> on Mon, 22 Jan 2001 16:44:56 -0500

I know this isn't really a db related question, but it does have to do 

w/ the project I'm working on and that does relate to db problems.  Our

db has user's SSN w/o the hyphens so my question is, how do you get rid

of the hyphens in the user's input.  For example, in our db we have a 

user's SSN as 123456789 but they put it in as 123-45-6789 and I want to

get rid of the hyphens so we can make a match.  Is there functions 

VBScript offers or any method of getting rid of these hyphens.  Thanks



JR Shortall

----------------------------------------

JR Shortall

Email: John.Shortall@e...

President, ECRH

http://www.elon.edu/ecrh



Message #2 by "Blake, Shane" <Shane.Blake@p...> on Mon, 22 Jan 2001 16:58:11 -0500
ssn = replace(ssn, "-", "")



if you havn't done so yet, you can download the vbscript documentation in a

windows help file format from microsoft's website... a must have



shane

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

From: JR Shortall [mailto:John.Shortall@e...]

Sent: Monday, January 22, 2001 4:45 PM

To: ASP Databases

Subject: [asp_databases] Parsing through data







I know this isn't really a db related question, but it does have to do 

w/ the project I'm working on and that does relate to db problems.  Our

db has user's SSN w/o the hyphens so my question is, how do you get rid

of the hyphens in the user's input.  For example, in our db we have a 

user's SSN as 123456789 but they put it in as 123-45-6789 and I want to

get rid of the hyphens so we can make a match.  Is there functions 

VBScript offers or any method of getting rid of these hyphens.  Thanks



JR Shortall

----------------------------------------

JR Shortall

Email: John.Shortall@e...

President, ECRH

http://www.elon.edu/ecrh



Message #3 by "Wally Burfine" <oopconsultant@h...> on Mon, 22 Jan 2001 22:52:56 -0000
Try this:

strSSN=join(Split(strSSN,"-"))





>From: JR Shortall <John.Shortall@e...>

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] Parsing through data

>Date: Mon, 22 Jan 2001 16:44:56 -0500

>

>

>I know this isn't really a db related question, but it does have to do

>w/ the project I'm working on and that does relate to db problems.  Our

>db has user's SSN w/o the hyphens so my question is, how do you get rid

>of the hyphens in the user's input.  For example, in our db we have a

>user's SSN as 123456789 but they put it in as 123-45-6789 and I want to

>get rid of the hyphens so we can make a match.  Is there functions

>VBScript offers or any method of getting rid of these hyphens.  Thanks

>

>JR Shortall

>----------------------------------------

>JR Shortall

>Email: John.Shortall@e...

>President, ECRH

>http://www.elon.edu/ecrh

>

>
Message #4 by "Dallas Martin" <dmartin@z...> on Mon, 22 Jan 2001 20:15:50 -0500
ssn = replace(ssn,"-","")





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

From: "JR Shortall" <John.Shortall@e...>

To: "ASP Databases" <asp_databases@p...>

Sent: Monday, January 22, 2001 4:44 PM

Subject: [asp_databases] Parsing through data





>

> I know this isn't really a db related question, but it does have to do

> w/ the project I'm working on and that does relate to db problems.  Our

> db has user's SSN w/o the hyphens so my question is, how do you get rid

> of the hyphens in the user's input.  For example, in our db we have a

> user's SSN as 123456789 but they put it in as 123-45-6789 and I want to

> get rid of the hyphens so we can make a match.  Is there functions

> VBScript offers or any method of getting rid of these hyphens.  Thanks

>

> JR Shortall

> ----------------------------------------

> JR Shortall

> Email: John.Shortall@e...

> President, ECRH

> http://www.elon.edu/ecrh

>

>
Message #5 by jmuldoon@u... on Wed, 24 Jan 2001 00:37:37 -0000
Wally:



I went through my Wrox Books on ASP but couldn't find an explanation of

your code:



strSSN=join(Split(strSSN,"-"))



It looks like a nice clean way of manipulating strings. Can you tell me

where to find details on the syntax.



Thanks,



Joe

Message #6 by Imar Spaanjaars <Imar@S...> on Wed, 24 Jan 2001 08:30:31 +0100
Hi Joe,



Go to http://msdn.microsoft.com/scripting/ , click on VB Script and choose 

for documentation.

Basically what this code does is splitting a string based on the - 

character. This results in an array filled with the elements of the string 

without the - character.



Example sTest = 123-456-789



arrTest = Split(sTest,"-")



This results in an array with the following values:



arrTest(0) = "123"

arrTest(1) = "456"

arrTest(2) = "789"



Now Join is used to combine the elements of an array back into one string:



sTest = Join(arrTest)



This will take the three elements of arrTest and combine them back into one 

string, so sTest is now "123456789"



Personally, I prefer the Replace method. It seems more natural to remove 

the - character by replacing it with nothing, than it is to create an array 

first and join that back together again.

But the Join / Split combination can come in handy every now and then.



HtH



Imar





At 12:37 AM 1/24/2001 +0000, you wrote:

>Wally:

>

>I went through my Wrox Books on ASP but couldn't find an explanation of

>your code:

>

>strSSN=join(Split(strSSN,"-"))

>

>It looks like a nice clean way of manipulating strings. Can you tell me

>where to find details on the syntax.

>

>Thanks,

>

>Joe



Message #7 by "Wally Burfine" <oopconsultant@h...> on Wed, 24 Jan 2001 14:10:20 -0000
Joe,



The Split function is a VBA function with the following syntax:



Split(expression[, delimiter[, count[, compare]]])



Split parses a single string containing delimited values into an array.

where:

    delimiter is the character used to delimit substrings in expression

        Default is space



    count is the number of strings to return (if missing the default is to 

return all substrings, one per array element)



    compare is the method of comparison : (vbBinaryCompare is the

         default but you can use vbTextCompare. both are

         intrinsic to VBA.)





The Join function concatinates the elements of an array into a delimited 

string:



Join(array[,delimiter])



Returns a string. The default delimiter is a space.



Wally Burfine





>From: jmuldoon@u...

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] Re: Parsing through data

>Date: Wed, 24 Jan 2001 00:37:37 -0000

>

>Wally:

>

>I went through my Wrox Books on ASP but couldn't find an explanation of

>your code:

>

>strSSN=join(Split(strSSN,"-"))

>

>It looks like a nice clean way of manipulating strings. Can you tell me

>where to find details on the syntax.

>

>Thanks,

>

>Joe

>

  Return to Index