You answered the question below some time ago and I need a similar response, however it doesn't quite work. Once the value gets to 0.6 it then needs to go to 1 and then 1.1, 1.2 and so on. With your code the value goes from 0.6 to 1.6, 2.6, 3.6 and so on due to the Else X = X + 1.0. I'm guessing it needs an exception of some sort to keep it on a 0.1 increase but stopping at 0.6.
Thanks, Adam
Visual Basic - adding numbers Expert: Richard Rost - 5/29/2008
Question Hi Richard, I am currently making a program for my school to use for their cricket team. However I have trouble adding up the amount of Overs. How do I tell VB to count to 0.6 before adding 1?
More specifically... When a decimal number reaches 0.6, 1 is added to the current value each time. i.e. 1.6 then +1, 2.6 then +1.
Answer I'm assuming you're adding up by 0.1 until you get to 0.6.
In that case, you could say:
'If X < 0.6 Then ' X = X + 0.1 'Else ' X = X + 1.0 'End If
Easy enough? Answer from Richard Rost:
Well, just change the code a little bit:
If X < 0.6 or X > 0.6 then X = X + 0.1 Else X = 1 End If
Basically if I understand what you're telling me, unless X is exactly 0.6 then you need to add 0.1 to it, otherwise, if it is 0.6, set it equal to 1.0.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Visual Basic Forum.