473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem Variable

Fox
Hi,

Can anyone tell me how can I create a variable which
will list numbers in a row and then use it in a CASE
within a Select Case?

I need it in a varaible because it has to be in an include
page. It needs to be used by each instance of the ap and
the numbers will change for different instances.

examples that don't work
baddivisions = 100,200,300,400,500,600,700
baddivisions = (100,200,300,400,500,600,700)
baddivisions = 100 & "," & 200 & "," & etc

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")

Thanks,
Fox
Jul 19 '05 #1
11 1400

"Fox" <fox @ connexions .net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
Hi,

Can anyone tell me how can I create a variable which
will list numbers in a row and then use it in a CASE
within a Select Case?

I need it in a varaible because it has to be in an include
page. It needs to be used by each instance of the ap and
the numbers will change for different instances.

examples that don't work
baddivisions = 100,200,300,400,500,600,700
baddivisions = (100,200,300,400,500,600,700)
baddivisions = 100 & "," & 200 & "," & etc

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")


Not sure I understand what you're trying to do exactly... are you trying to
match against the entire string? As in:

Division("DivNumber") = 100,200,300,400,500,600,700

Or are you trying to match where the value is ONE OF the values in that
list? I assume the latter.

' Create an array to hold the values
baddivisions = Split("100,200,300,400,500,600,700",",")

Do While Not Division.EOF
' Check DivNumber against array
donothing = "no"
For i = 0 to Ubound(baddivisions)
If Division("DivNumber") = CInt(baddivisions(i)) Then
donothing = "yes"
End If
Next
If donothing = "no" Then
Response.Write("<option>" & Division("DivNumber") & "</option>")
End If
Division.MoveNext
Loop
Hope this helps.
Regards,
Peter Foti
Jul 19 '05 #2
What should yield a true result? If Division("Number") =
"100,200,300,400..." or if Division("Number") is just ONE of the numbers in
that string?

Ray at work

"Fox" <fox @ connexions .net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
Hi,

Can anyone tell me how can I create a variable which
will list numbers in a row and then use it in a CASE
within a Select Case?

I need it in a varaible because it has to be in an include
page. It needs to be used by each instance of the ap and
the numbers will change for different instances.

examples that don't work
baddivisions = 100,200,300,400,500,600,700
baddivisions = (100,200,300,400,500,600,700)
baddivisions = 100 & "," & 200 & "," & etc

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")

Thanks,
Fox

Jul 19 '05 #3
Fox
Hi,

I'm looking for a match with any number within the string.

Thanks,
Fox

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#P**************@TK2MSFTNGP09.phx.gbl...
What should yield a true result? If Division("Number") =
"100,200,300,400..." or if Division("Number") is just ONE of the numbers in that string?

Ray at work

"Fox" <fox @ connexions .net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
Hi,

Can anyone tell me how can I create a variable which
will list numbers in a row and then use it in a CASE
within a Select Case?

I need it in a varaible because it has to be in an include
page. It needs to be used by each instance of the ap and
the numbers will change for different instances.

examples that don't work
baddivisions = 100,200,300,400,500,600,700
baddivisions = (100,200,300,400,500,600,700)
baddivisions = 100 & "," & 200 & "," & etc

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")

Thanks,
Fox


Jul 19 '05 #4
Here is what I usually do:

baddivisions = ",100,200,300,"

if instr( baddivisions, "," & Division("DivNumber") & "," ) > 0 then
bad...
else
....

if all of your division #s are the same length you can loose the extra
commas in the instr statement.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Fox" <fox @ connexions .net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm looking for a match with any number within the string.

Thanks,
Fox

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#P**************@TK2MSFTNGP09.phx.gbl...
What should yield a true result? If Division("Number") =
"100,200,300,400..." or if Division("Number") is just ONE of the numbers

in
that string?

Ray at work

"Fox" <fox @ connexions .net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
Hi,

Can anyone tell me how can I create a variable which
will list numbers in a row and then use it in a CASE
within a Select Case?

I need it in a varaible because it has to be in an include
page. It needs to be used by each instance of the ap and
the numbers will change for different instances.

examples that don't work
baddivisions = 100,200,300,400,500,600,700
baddivisions = (100,200,300,400,500,600,700)
baddivisions = 100 & "," & 200 & "," & etc

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")

Thanks,
Fox



Jul 19 '05 #5
Fox
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places. As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.

Regards,
Fox

"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:Ou*************@TK2MSFTNGP11.phx.gbl...
Here is what I usually do:

baddivisions = ",100,200,300,"

if instr( baddivisions, "," & Division("DivNumber") & "," ) > 0 then
bad...
else
...

if all of your division #s are the same length you can loose the extra
commas in the instr statement.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Fox" <fox @ connexions .net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm looking for a match with any number within the string.

Thanks,
Fox

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#P**************@TK2MSFTNGP09.phx.gbl...
What should yield a true result? If Division("Number") =
"100,200,300,400..." or if Division("Number") is just ONE of the
numbers in
that string?

Ray at work

"Fox" <fox @ connexions .net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Can anyone tell me how can I create a variable which
> will list numbers in a row and then use it in a CASE
> within a Select Case?
>
> I need it in a varaible because it has to be in an include
> page. It needs to be used by each instance of the ap and
> the numbers will change for different instances.
>
> examples that don't work
> baddivisions = 100,200,300,400,500,600,700
> baddivisions = (100,200,300,400,500,600,700)
> baddivisions = 100 & "," & 200 & "," & etc
>
> THIS SNIPIT IS WHERE I NEED TO PUT IT:
>
> Do while NOT Division.EOF
> Select Case Division("DivNumber")
> case baddivisions <---- this works w/ numbers not w/ variable
> donothing = "yes"
> case else
> Response.Write("<option>" & Division("DivNumber") & "</option>")
> END SELECT
> Division.MoveNext
> Loop
> Response.Write ("</select><br>")
>
> Thanks,
> Fox
>
>



Jul 19 '05 #6
Fox wrote:
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places. As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.

Do you have the vbscript documentation? If not, get it here:
http://tinyurl.com/7rk6

If you do have it, please look up InStr and read it. If it is still unclear,
then post back here and ask for help in understanding it.
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #7
Fox
Thanks for the link to the docs.
I will add this to the 3,000 pages
of reference books on ASP I already
have. So far none have information
regarding fitting that type of variable
into an INSTR in that way. If these
docs get that detailed, I will be in
heaven.

Fox
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:em*************@TK2MSFTNGP10.phx.gbl...
Fox wrote:
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places. As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.
Do you have the vbscript documentation? If not, get it here:
http://tinyurl.com/7rk6

If you do have it, please look up InStr and read it. If it is still

unclear, then post back here and ask for help in understanding it.
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #8
Fox wrote:
Thanks for the link to the docs.
I will add this to the 3,000 pages
of reference books on ASP I already
have. So far none have information
regarding fitting that type of variable
into an INSTR in that way.


Seriously? You read the documentation on the InStr function and don't have
the answer to your questions below?
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places.
He is merely concatenating commas around the search value to make sure the
proper match is found. For example, let's say Division("DivNumber") contains
"20". If you do this

Instr("100,200,300", "10")

You will get a 5 returned because "20" is found in the fifth position of
"100,200,300". To prevent this, he put commas at the beginning and end of
the string to be searched:

",100,200,300,"

and then he put commas around the value contained in Division("DivNumber"),
so the resulting statement, once the concatenation is performed, looks like
this:

Instr(",100,200,300,", ",20,")

which now returns 0 because ",20," cannot be found in ",100,200,300," .
",20" can be found, but not ",20,"

As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.


This question is definitely answered by the documentation. Here, from the
documentation:

"[Instr] Returns the position of the first occurrence of one string within
another."

InStr([start, ]string1, string2[, compare])
....
Return Values
The InStr function returns the following values:
If string1 is zero-length. InStr returns 0
If string1 is Null, InStr returns Null
If string2 is zero-length, InStr returns start
If string2 is Null, InStr returns Null
If string2 is not found, InStr returns 0
If string2 is found within string1, InStr returns Position at which match is
found
If start > Len(string2), InStr returns 0

So, looking at the above, when will the value returned from Instr() be >0?

Bob Barrows

-- Microsoft MVP - ASP/ASP.NETPlease reply to the newsgroup. This email
account is my spam trap so Idon't check it very often. If you must reply
off-line, then remove the"NO SPAM"
Jul 19 '05 #9
Fox wrote:
Thanks for the link to the docs.
I will add this to the 3,000 pages
of reference books on ASP I already
have. So far none have information
regarding fitting that type of variable
into an INSTR in that way.


Seriously? You read the documentation on the InStr function and don't have
the answer to your questions below?
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places.
He is merely concatenating commas around the search value to make sure the
proper match is found. For example, let's say Division("DivNumber") contains
"20". If you do this

Instr("100,200,300", "20")

You will get a 5 returned because "20" is found in the fifth position of
"100,200,300". To prevent this, he put commas at the beginning and end of
the string to be searched:

",100,200,300,"

and then he put commas around the value contained in Division("DivNumber"),
so the resulting statement, once the concatenation is performed, looks like
this:

Instr(",100,200,300,", ",20,")

which now returns 0 because ",20," cannot be found in ",100,200,300," .
",20" can be found, but not ",20,"

As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.


This question is definitely answered by the documentation. Here, from the
documentation:

"[Instr] Returns the position of the first occurrence of one string within
another."

InStr([start, ]string1, string2[, compare])
....
Return Values
The InStr function returns the following values:
If string1 is zero-length. InStr returns 0
If string1 is Null, InStr returns Null
If string2 is zero-length, InStr returns start
If string2 is Null, InStr returns Null
If string2 is not found, InStr returns 0
If string2 is found within string1, InStr returns Position at which match is
found
If start > Len(string2), InStr returns 0

So, looking at the above, when will the value returned from Instr() be >0?

Bob Barrows

-- Microsoft MVP - ASP/ASP.NETPlease reply to the newsgroup. This email
account is my spam trap so Idon't check it very often. If you must reply
off-line, then remove the"NO SPAM"
Jul 19 '05 #10
"Fox" wrote:

THIS SNIPIT IS WHERE I NEED TO PUT IT:

Do while NOT Division.EOF
Select Case Division("DivNumber")
case baddivisions <---- this works w/ numbers not w/ variable
donothing = "yes"
case else
Response.Write("<option>" & Division("DivNumber") & "</option>")
END SELECT
Division.MoveNext
Loop
Response.Write ("</select><br>")


I understand neither (a) why you need a Select Case statement here, as you
only have two conditions, nor (b) why you seem to be avoiding arrays for
storing your list. For example,

BadDivisions = Array(100,200,300,400,500,600,700)
Do While Not Division.EOF
DoNothing = False
For Each n In BadDivisions
If Division("DivNumber") = n Then
DoNothing = True
End If
Next
If Not DoNothing Then
Response.Write("<option>" & Division("DivNumber") & "</option>")
End If
Division.MoveNext
Loop

Of course, you could eliminate all of the interior looping with a Scripting
Dictionary or just abstract the whole thing, as I do below with a customized
JScript Array Object. This could be your include:

<SCRIPT RUNAT="Server" LANGUAGE="JScript">
var BadDivisions = [100,200,300,400,500,600,700]
BadDivisions.Item = function(n) {
for (var x in this) if (n==this[x]) return true
return false
}
</SCRIPT>

You could put it anywhere in your VBScript document and still use it. In
your example, the logic distills to this:

Do While Not Division.EOF
If Not BadDivisions.Item(Division("DivNumber").Value) Then
Response.Write("<option>" & Division("DivNumber") & "</option>")
End If
Division.MoveNext
Loop

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #11
As other posters have mentioned, the docs on INSTR should explain what ">0"
means. In case you still don't understand. INSTR returns the first character
location where a substring is found. If the string is not found then it
returns 0 (it will return null if one of the string parameters is null).

The reason for the extra commas is to prevent ambiguity, for instance

strList = "2,6,11,23"

If you search for "1" you will get a hit on "11". searching for ",1," will
prevent that but you must include the leading and trailing commas in the
list string as well or you will never match the first and last values.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Fox" <fox @ connexions .net> wrote in message
news:Od****************@TK2MSFTNGP10.phx.gbl...
Thanks, that worked perfectly.
But I don't understand all of the syntax.
If you have some time to break it down
I would appreciate it. I understand the
INSTR, have used it many times.
I don't understand the "," in the
various places. As for the ">0"
I am supposing this means that the
hits get counted and any hit will increase
the count by "1". That I did not know.

Regards,
Fox

"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:Ou*************@TK2MSFTNGP11.phx.gbl...
Here is what I usually do:

baddivisions = ",100,200,300,"

if instr( baddivisions, "," & Division("DivNumber") & "," ) > 0 then
bad...
else
...

if all of your division #s are the same length you can loose the extra
commas in the instr statement.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Fox" <fox @ connexions .net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm looking for a match with any number within the string.

Thanks,
Fox

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#P**************@TK2MSFTNGP09.phx.gbl...
> What should yield a true result? If Division("Number") =
> "100,200,300,400..." or if Division("Number") is just ONE of the numbers in
> that string?
>
> Ray at work
>
> "Fox" <fox @ connexions .net> wrote in message
> news:OM*************@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > Can anyone tell me how can I create a variable which
> > will list numbers in a row and then use it in a CASE
> > within a Select Case?
> >
> > I need it in a varaible because it has to be in an include
> > page. It needs to be used by each instance of the ap and
> > the numbers will change for different instances.
> >
> > examples that don't work
> > baddivisions = 100,200,300,400,500,600,700
> > baddivisions = (100,200,300,400,500,600,700)
> > baddivisions = 100 & "," & 200 & "," & etc
> >
> > THIS SNIPIT IS WHERE I NEED TO PUT IT:
> >
> > Do while NOT Division.EOF
> > Select Case Division("DivNumber")
> > case baddivisions <---- this works w/ numbers not w/ variable
> > donothing = "yes"
> > case else
> > Response.Write("<option>" & Division("DivNumber") & "</option>")
> > END SELECT
> > Division.MoveNext
> > Loop
> > Response.Write ("</select><br>")
> >
> > Thanks,
> > Fox
> >
> >
>
>



Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the...
10
by: Jack | last post by:
How would I add a variable that I will assign to a list of $_POST variables that I extract from a form? My form passes a value for $q. That works fine. What I want to do is run an if/else on it...
0
by: I.P. | last post by:
------=_NextPart_000_03FF_01C368A4.75720DC0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Hi, it's my story. I have two 4.0.14 mysql server on...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
6
by: Boris | last post by:
Hi, I have a question regarding XSLT . Is it possible to output elements in an XML between two values. Here is an XML example of my data : <root> <stations> <station> <name>A</name>
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
5
by: dav3 | last post by:
I am by no means an ultra slick programmer and my problem solving skills.. well they leave much to be desired. That being said I have been working on the following problem for the past few days and...
3
by: crater | last post by:
Today I ran into a problem that had me completely baffled. A function that I have just written, processes data in any one of 4 different data grids. Within a for() loop I need to call another...
11
by: =?ISO-8859-1?Q?Jean=2DFran=E7ois_Michaud?= | last post by:
Context: I'm trying to compare XML tree fragments and I'm doing so by outputting the attributes of each element in the tree and outputting it to a string then normalizing the strings. Then I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.