|
-
Oct 29th, 2007, 09:00 AM
#1
Thread Starter
Addicted Member
Easiest Question Ever
The code below should print out the multiplication table from 1 to 9. The for loops are fine; however, the logic on the Do until loop is the part causing the problem. Supposedly it will exit the do until loop once (answer = (i*j)) returns true. But this does not happen. If I use <> instead of = it will increment the j count, but it does not care what I enter for answer. I am a little confused as to why this does not work the way I was thinking it did. Please let me knwo if you can help shed some light on this logic with me.
I appreciate your time and help.
Code:
<script type="text/vbscript">
Dim i
Dim j
Dim answer
For i = 1 to 9 Step 1
For j = 0 to 9 Step 1
Do
answer = InputBox("Whats " & i & " * " & j & "?")
Loop Until(answer = i * j)
Next
Next
</script>
Thank you/þankung/Danke/Vjelpa ye
Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.
-
Oct 29th, 2007, 09:42 AM
#2
Re: Easiest Question Ever
It's because you are comparing a number to a string. Change this line
Loop Until(answer = i * j)
to
Loop Until(cint(answer) = i * j)
-
Oct 29th, 2007, 05:05 PM
#3
Thread Starter
Addicted Member
Re: Easiest Question Ever
I knew it was a type problem all along! Thanks for your help!!
Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|