Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting in vb

Status
Not open for further replies.

sawle

Programmer
Apr 25, 2008
4
0
0
GB
i have created a sort of petrol pump simulation lol
which simulates 7 segment LCD screen and the numbers that are displayed on LCD screen are also displayed in txt boxes (so customers can see the LCD screen and the owner is able to see amount of petrol dispensed on his console in his office)

the number is in the xx.x format, now i wonder how can i get the last digit to go up in fives, in other words to count up in fives, but last digit only

any ideas
 
check out the round function.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Hi and welcome to Tek-Tips. Please read faq222-2244 to see how to get the best from these forums.

For this question the standard method is to multiply by 2, take the integer value then divide by 2. To round up, just add 1 to the integer value before dividing
Code:
y = (Int(x*2))/2

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
o yh and one more thing
how do u write a vallidation so you can only enter integer numbers in txt box
so if you enter a letter then a error message pops up

btw that rounding works very nice

thanx
 
its ok sort it now
simple

thanx a lot guys
nice forum btw i will stick to this one
 
>how do u write a vallidation so you can only enter integer numbers in txt box

You could use the keypress event of the text box and only allow numbers and bacspace key.

if keyascii<48 and keyascii > 57 then
keyascii=0
end if

just to get you started.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top