serious sub routine bug

T

Tim

Here is a description of my problem...

call mysub (5, 10)

sub mysub (valA, valB)
response.write valB
valA = valA - 1
response.write valB
end sub

this should print out 10 followed by 10.
it doesn't.
it prints 10 followed by 9.

it is taking the 1 off the wrong variable! HOW!
it is not a typo, I've got everyone in the office to check out my code, it
is a real genuine unbelievable bug.

is it known? is it fixable?


Tim


--
 
W

WIlliam Morris

Assuming that you've typed your code correctly, you never do any math
against valB. (No offence meant, but I'm having trouble taking this
question seriously - IF you've typed your code correctly, that is)
 
T

Tim

I don't understand what you mean?

at least 4 people checked the code.

it is a bug.



WIlliam Morris said:
Assuming that you've typed your code correctly, you never do any math
against valB. (No offence meant, but I'm having trouble taking this
question seriously - IF you've typed your code correctly, that is)
 
R

Ray at

I get expected results too. Copy and paste your exact code into a reply
here. Your sub would be the same if it were:

Sub mysub(valA, valB)
response.write valB
response.write valB
End Sub

There's something you're not telling us, or you transcribed your subroutine
wrong when you posted it here. Copy and paste it exactly as it is and post
it here.

Ray at work

Tim said:
I don't understand what you mean?

at least 4 people checked the code.

it is a bug.



WIlliam Morris said:
Assuming that you've typed your code correctly, you never do any math
against valB. (No offence meant, but I'm having trouble taking this
question seriously - IF you've typed your code correctly, that is)
code,
 
B

Bullschmidt

Maybe it's a variable scoping problem. Some suggestions to experiment
with:

Try parameter names of pvalA and pvalB.

Try using Option Explicit toward the top of the page and dim all your
variables in the appropriate places.

I doubt this would make a difference but try using a function instead of
a sub.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
P

Phillip Windell

It outputs 10 and 10 for me, just like it should. I pasted your code
into a page right out of the message.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
T

Tim

this is an exact copy, the only difference is I have removed the rest of the
sub after the point it makes it's mistake

sub showline(thesize,textsize,rs)

response.write thesize
response.write textsize

textsize=textsize-1
adcolor="white"
textcolor="black"
textcolor2="black"

response.write thesize
response.write textsize

'there is more after this point, but the damage is already done.

end sub
 
R

Ray at

Okay, so what does this do for you?
<%
Call showline(1, 2, 0)

sub showline(thesize,textsize,rs)

response.write thesize
response.write textsize

textsize=textsize-1


response.write thesize
response.write textsize

'there is more after this point, but the damage is already done.

end sub
%>
It should return:
1211


What do you get?

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,646
Members
47,247
Latest member
GabrieleL2

Latest Threads

Top