|
-
May 11th, 2001, 11:21 PM
#1
Loops
I wrote this program for a project, thought it was working but it ends up doin what its suppose to once and then when u try to click an operation again it skips my Do..While loop.. why, what do i do to fix it??!?! Help!!! Fast!!!!
Here's ONE section of the code...
'Set Do..Whille loop to enter values to add together and enter "999" to stop the inputbox.
Do While result <> 999
result = InputBox("Enter the values <999 to stop>")
If result <> 999 Then
x = x + result
End If
Loop
'Ask the user to enter the answer they think it is
response = InputBox("What do you think the answer is?", "Answer")
'Display a sad face if their answer is wrong or a happy face if the answer is correct
If response = x Then
frmHappy.Visible = True
response = MsgBox("Congratulations! You got it right!", vbExclamation, "Happy")
Else
frmSad.Visible = True
response = MsgBox("No, I'm sorry.. You should try again, or would you like to see the right answer?", vbYesNo, "Sad")
If response = vbYes Then
MsgBox ("The correct answer is " & x)
ElseIf response = vbNo Then
frmSad.Show
End If
End If
Smile - somewhere its helping someone.
-
May 12th, 2001, 12:30 AM
#2
Re: Loops
nm - i just went back and made my global variables local and it works...
now i just have another prob...
i dont know exactly how to do tell it to subract and divide.
i got add and multiply good to go but when i try to put more than 2 values in subtract and/or divide it doesnt get the answers it should... how do i fix it?
Smile - somewhere its helping someone.
-
May 12th, 2001, 07:43 AM
#3
Re: Loops
It will skip your do while loop because, as you said, was a global variable and still retained the value of '999' (your number to stop the process) the next time you need to use it. As far as fixing your calculation problems, post your code what you have already.
David Paulson
-
May 12th, 2001, 08:33 AM
#4
Re: Loops
Not sure if this is what you're looking for:
If you're operating on the previous value:
substract:
x = result - x
divide:
x = result / x
-Cool Bizs
Good Luck,
-Cool Bizs
-
May 12th, 2001, 11:19 AM
#5
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
|