PDA

Click to See Complete Forum and Search --> : REALLY need help!


kazooie21
Nov 22nd, 1999, 04:42 AM
This code won't work! Anyone know what's wrong?
Dim curSales as Currency
curSales = Val(Inputbox("Enter a sales amount"))
do
curSales = Val(Inputbox("Enter a sales amount"))
Print curSales * .1
Loop Until curSales < = 0

Ice
Nov 22nd, 1999, 04:47 AM
Constantly asking user (look out for those people) to change a variable you are working with And using as loop control.

i.e. if the user does not change curSales, your code leaves curSales = curSales and thus curSales will not be <=0

try again

[This message has been edited by Ice (edited 11-22-1999).]

enevoljm
Nov 22nd, 1999, 04:56 AM
Can't tell you what's wrong without knowing what it's supposed to do.

However, here's what I'm assuming this code is supposed to do: ask the user for a sales amount, print what they entered (* .1) and keep doing that until the sales amount the user entered multiplied by .1 is <= 0 (which means if the user entered a 0 the loop should stop.

If this is the case, the code won't print the first amount entered by the user. Copying the print statement to right before the do statement would fix that.

Where are you trying to print the sales amounts to? The printer? Then use printer.print? Or perhaps the destination is a field on the form? I can't tell from your code snippet.

By the way, this isn't a great technique for user input. How does the user know how to stop the program from asking for more input?

kazooie21
Nov 22nd, 1999, 09:49 AM
Thanks for the advice! It's not an actual program. It's an exercise in the text we're using for my VB class. We have to identify what's wrong with it, but you told me. I believe that's right.

------------------
kazooie21