D
DrNoose
I'm helping a friend with a program that uses random numbers. The user
tells the program how many questions to ask and the program will either
add, sub, multiply, or divide 2 numbers. The range of random numbers is
from 0-100. The problem, if there is one, is that many times the 2nd
number is larger when dividing the numbers causing you to have to give a
decimal answer. Is there a way to code the division case selection so
that it only returns a number without being a decimal?
Here is the code for case 4, which does the division of the random numbers.
**********************************************************************
Case 4
'Generate question.
sUserAnswer = InputBox("What is " & iOperand1 & _
" / " & iOperand2)
' Determine if user's answer was correct and add an
' appropriate item to the multi-column list box.
If Val(sUserAnswer) = iOperand1 / iOperand2 Then
lstResults.AddItem iOperand1 & " / " & _
iOperand2 & ";" & sUserAnswer & ";Correct"
Else
lstResults.AddItem iOperand1 & " / " & _
iOperand2 & ";" & sUserAnswer & ";Incorrect"
End If
Thanks!
tells the program how many questions to ask and the program will either
add, sub, multiply, or divide 2 numbers. The range of random numbers is
from 0-100. The problem, if there is one, is that many times the 2nd
number is larger when dividing the numbers causing you to have to give a
decimal answer. Is there a way to code the division case selection so
that it only returns a number without being a decimal?
Here is the code for case 4, which does the division of the random numbers.
**********************************************************************
Case 4
'Generate question.
sUserAnswer = InputBox("What is " & iOperand1 & _
" / " & iOperand2)
' Determine if user's answer was correct and add an
' appropriate item to the multi-column list box.
If Val(sUserAnswer) = iOperand1 / iOperand2 Then
lstResults.AddItem iOperand1 & " / " & _
iOperand2 & ";" & sUserAnswer & ";Correct"
Else
lstResults.AddItem iOperand1 & " / " & _
iOperand2 & ";" & sUserAnswer & ";Incorrect"
End If
Thanks!