| | |
|
Active Server Pages ASP ASP.NET .aspx .ascx Web HTML Developer Internet Microsoft Web Services Visual Studio .NET CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Re: Count the number of values in an array string??? |
From: |
jason pinhut |
Date: |
12/25/2002 10:53:30 PM |
IP: |
195.92.67.65 |
you don't necessarily have to count the values first. below is some code i used to split an array from a multi-select (i wanted exactly 4 values to have been chosen) you may be able to tweak this method if you don't have a high maximum number of values. the basic idea is to check for a comma at the end of each value. no comma means you have the last value, so you know when to stop the loop. i chop off the comma and make the result a session variable. it's a bit ragged, but it might give you some ideas
<%
strSentence = Request.Form("choice")
intcomma = InStr(strSentence, ",")
If len(strSentence) < 1 OR intcomma = 0 Then
Response.Redirect "invalid.asp"
End If
Dim OneDimArray
OneDimArray = split(strSentence)
For i=0 to 3
If i = 0 Then
a = OneDimArray(i)
a= left(a,len(a)-1)
Session("a") = a
End If
If i= 1 Then
b = OneDimArray(i)
intcomma1 = InStr(b, ",")
If len(b) < 1 or intcomma1 = 0 Then
Response.Redirect "blobby.asp"
End If
b=left(b,len(b)-1)
Session("b") = b
End If
If i = 2 Then
c = OneDimArray(i)
intcomma2 = InStr(c,",")
If len(c) <1 or intcomma2 = 0 Then
Response.Redirect "blobby2.asp"
End If
c = left(c,len(c)-1)
Session("c") = c
End If
If i = 3 Then
d= OneDimArray(i)
Session("d") = d
If len(d) = 0 OR len(d) > 3 Then
Response.Redirect "invalid.asp"
End If
End If
Next%> |
Previous Message
Follow Up - Re: Count the number of values in an array string??? - SI 2/9/2003 8:14:54 AM
|
|

|
|
|
|