Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using variable in VBScript expression.

Status
Not open for further replies.

bhuizinga

Programmer
Sep 5, 2001
2
NL
I'm trying to use a variable in an VBScript expression, but I'm having a problem.

In a document there are several input boxes named Minute1, Minute2, etc.
intNummer is a variable with the integer value. Sofar no problem, but now I want to use this variable in a statement. The first statement is working just fine, but the second one is killing me.

1) if document.Minute1.value = 90 then ...
2) if document.Minute&intNummer.value = 90 then ...

What am I doing wrong ??? :-(

Thx in advance,
Bart
 
& is "and" operator in JavaScript
in VBScript you need "and" (without quotes).
 
Dianal, thx for your very quick response. I have tried several ways of replacing the ampersand with the word and, but still getting errors. Would you be so kind to write down the exact statement as it should be ?

for example :
if document.minuteandintNummer.value = 90 then ...

Thx again,
Bart
 
Try
If document.minute = 90 AND intNummer.value = 90 Then

unless you need

If document.minute.value = 90 and intNummer.value = 90 Then

Each part of the true/false needs a seperate evaluation. Sometimes it is easier to picture if you use parenthesis e.g.

If (document.minute.value = 90) AND (intNummer.value = 90) Then

hth

Parke
 
I think people are not understanding your problem. You want the name of the object to vary, by appending the string value of intnummer to the root of the name (minute).

I have done such a thing in VBA. I think I used another variable to do it, for debugging. It is something like
"minute" + str$(intnummer). this returns a string of the correct form. I don't know if doing it in line will get the right object -- try it. (I'm writing from Linux so I can't try it now.)
 
Hello, bhuizinga.

Depending on how the form/input is structured of which you did not provide a clue, the following may or may not work for your case :

If document.minute(intNummer-1).value = 90 Then ...

(minute() zero based).

regards - tsuji
 
Hi,

I think bhuizinga is trying to handle Minute1,Minute2,
Minutes3 and so on, and these are OBJECTS ?

Maybe Array function will solve this,

<SCRIPT LANGUAGE = &quot;VBScript&quot;>
Dim myMinute
myMinutes = Array(Minute1,Minute2,........)
nCount = 0
Do While nCount < yourmax 'number of minute
if document.myMinutes(ncount).value = 90 then
.............
.............
End If
nCount = nCount+1
Loop
</SCRIPT>





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top