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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to get a variable to increment

Status
Not open for further replies.

fergman

Technical User
Oct 19, 2000
91
US
I've posted several versions of this main() function, and gotten lot's of help on it, and yet here I am again, stuck.
I've got a counter that I'm trying to increment every time the main() is run. the number always stays at 1
also is their an equivalent variableName++ in vbscript for counting?
It's like this:

dim classNumber
classNumber = 0

call main
sub main()

classNumber = classNumber + 1
response.write classNumber & "= classNumber"

if varId <> &quot;&quot; then
response.write &quot;varId = &quot; & varId
id = varId
varDepartment = &quot;&quot;
varCourse = &quot;&quot;
varSection = &quot;&quot;
varRecommended = &quot;&quot;
end if

call getDepartment

if depTrue = 1 then
call getCourse
end if

if couTrue = 1 then
call getSection
end if

if secTrue = 1 then
call getRecommended
end if

if recTrue = 1 then
formState = 1
end if


if formState = 1 AND varRecommended = &quot;yes&quot; OR varRecommended = &quot;no&quot; then
call writeDB
%>
<SCRIPT Language=&quot;JavaScript&quot;>
document.form1.submit()
</script>
<%
end if

end sub
 
No, in fact .Net only supplied the += 1 and not ++ as an option for incrementing, despite how much other stuff they blatently ripped off from Java :)

Also, I'm assuming your calling that main statement several times for a single page, correct? Not trying to count how many times you have called it across many pages.
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
I'm only calling it once actually, and that might be the problem, the form actually submits everytime the user changes a control object (selectboxes mainly). and then at the end the form is submitted with no data to restart from the beginning.
The whole this is to run 8 times, or until the user clicks done is the idea. to do it 8 times I need to keep track of which run the user is on. I tried to do it in a sesion variable, but that doesn't seem to work either.
 
Why not write the counter into a hidden field and then just pull it out in the main, cInt, and increment, then the new incremented value will be written to the hidden field again.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
I tried that a little, I ended up with a type mismatch, I think I had something configured wrong, but that does sound like the best avenue. I guess i'll try that again and spend a little time trying to sort out the type mismatch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top