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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This is Driving me NUTS

Status
Not open for further replies.

DUF

Technical User
Mar 10, 2001
107
IE
I Have two TextBoxs on a form txtText1 and txtText2

In the txtText1 code window I have
txtText2.text = Round(txtText1 / 0.787654),2)

So as you type a figure into textbox1 the result apperars in textbox2,,,,,example inputing 12.99 into textbox1 result in textbox 2 is 16.49. Right this works as it should.

Problem

Input 31.11 the result should be 39.50 right !!!!! But the result is 39.5 What happend to the zero after the five, How can I get it to display 39.50 I have tryed Rounding,int,fix,Ccuy,Cdbl etc etc

Anyone have any ideas I am new to VB and can't get my head around this???
any help with much thanks

Duf


 
See the Format function in the Visual Basic Reference and see also "Different Formats for Different Numeric Values" so you can add commas, more digits or whatever.

For example:
txtText2.Text = Format(Round((txtText1 / 0.787654), 2), "###.00")
 
txtText2.Text = Format((txtText1 / 0.787654), "####0.00")
David Paulson

 
Duf
On the design Screen for the form in the properties of txtText2 there should be a dataformat property. Open that property up and click on the 'number' format, then set you decimal places to 2. Then you will get your 39.50. But be aware you will also get 1.00. I don't know if this what you need but a may be a place to start.

hth
Scoty ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Hey Thanks lads it works
thank you,thank you,thank you,thank you,thank you,thank you



Duf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top