Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: help me with this please


Message #1 by "Derek Halstead" <derekhalstead@u...> on Mon, 28 Aug 2000 8:45:51
Hi,

   I have a field name called clients in my table. The values that i enter 

into this field are like this: 1,2,3 or 1,5,8 in any order and can be more 

than 3 also.

So my question is how do i separate 1 from the group of 1, 2, 3 and how do 

i separate 5 from the group of 1,5,8.

Can you please help me with this.

Thanks alot in advance,

Derek

Message #2 by "Ken Schaefer" <ken@a...> on Tue, 29 Aug 2000 11:22:10 +1000
In VBScript you can use Split() (returns a zero based array)



eg



<%

strVar = "1,2,3"

arrResults = Split(strVar, ",")

%>



then..

arrResults(0) = 1

arrResults(1) = 2

arrResults(2) = 3



I don't know if you can do it in SQL



Cheers

Ken



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

From: "Derek Halstead" <derekhalstead@u...>

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

Sent: Monday, August 28, 2000 8:45 AM

Subject: [asp_databases] help me with this please





> Hi,

>    I have a field name called clients in my table. The values that i enter

> into this field are like this: 1,2,3 or 1,5,8 in any order and can be more

> than 3 also.

> So my question is how do i separate 1 from the group of 1, 2, 3 and how do

> i separate 5 from the group of 1,5,8.

> Can you please help me with this.

> Thanks alot in advance,

> Derek



Message #3 by Imar Spaanjaars <Imar@S...> on Mon, 28 Aug 2000 21:21:12 +0200
Use the split command This will return an array.



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



Expression is the string your are splitting, in your case a custom-build 

string, or the string returned from the Request.Form collection.

The delimiter in your case would be a comma.

Count is an optinal arggument, and determines the number of items to return.'

Compare is either vbBinaryCompare (with the value 0) or vbTextCompare (with 

the value 1)



The first performs a binary comparison (case sensitive) the latter performs 

a textual comparison.



So do something like this:



Dim aSplitNumbers

Dim sMyNumbers



sMyNumbers = Request.Form("myField") ' asume it contains "1,2,3"

aSplitNumbers = Split(sMyNumbers, ",")



Then you have the following array-elements



aSplitNumbers(0) = 1

aSplitNumbers(1) = 2

aSplitNumbers(2) = 3



Hope this helps.



Imar





At 08:45 AM 8/28/2000 +0000, you wrote:

>Hi,

>    I have a field name called clients in my table. The values that i enter

>into this field are like this: 1,2,3 or 1,5,8 in any order and can be more

>than 3 also.

>So my question is how do i separate 1 from the group of 1, 2, 3 and how do

>i separate 5 from the group of 1,5,8.

>Can you please help me with this.

>Thanks alot in advance,

>Derek

>

>---

>You are currently subscribed to asp_databases







  Return to Index