mathematical operations on text boxes
Hello
I have got the following code
Code:
CableLos = CableLoss.Text + OTSR_splitterLoss.Text
i stick the value 3 in cableloss.text
and 3 in OTSR_splitterloss.text
and i get the value 33 !!
can you guys tell me how to do a sum on these two text boxes.
Re: mathematical operations on text boxes
One of many ways would be to use the Val statement.
VB Code:
CableLos = Val(CableLoss.Text) + Val(OTSR_splitterLoss.Text)
Re: mathematical operations on text boxes
A good thing to remember is that any time that you use math on user input to be sure to convert it to a number. You can use Val() as RobDog suggested or one of the conversion functions.
CByte() - Byte
CInt() - Integer
CLng() - Long
CDbl() - Double
CSng() - Single
CCur() - Currency
Re: mathematical operations on text boxes
thanks dudes
i used the ccur to convert it to currencies
what would the difference between vall and ccur be?
does val return fractional numbers?
Re: mathematical operations on text boxes
Quote:
Originally Posted by Psyrus
A good thing to remember is that any time that you use math on user input to be sure to convert it to a number. You can use Val() as RobDog suggested or one of the conversion functions.
CByte() - Byte
CInt() - Integer
CLng() - Long
CDbl() - Double
CSng() - Single
CCur() - Currency
Unless it's a date, then use CDate()
Re: mathematical operations on text boxes
Quote:
Originally Posted by vb_student
does val return fractional numbers?
Val returns whole numbers. If you did a val on 3.5, it would return 4