text box rounding off!! i dont need it to round off


i been working with VB for a year now and i still have a lot of things to learn about it.. my program for a client is close to completion but there is just one thing i'm a little bit worried about.. its the figure for the textboxes rounding off if.. it does not round off when the focus is still on the textbox but when it has already lost focus, it rounds off to its whole number...ive tried setting up a variable declared as double data type but seems not to work still...tried the dataformat property of the text box but still does not work..i dont need it to round off because it is bound to a database field and my client wants accurate figures.. maybe i overlooked something or maybe i just do not know how.. need your help. thank you much.

If you enjoyed this post, subscribe for updates (it's free)

Example

For example, if the text box entry is 648.33, after the text box loses focus the entry automatically removes the decimal figure leaving it as just 648. Another example, if the enter the value ( or any value for that matter that has a decimal) 456.99, it changes the figure to 457 disregarding the decimal value. The application that im working on right now requires accurate figures hence i need it with the decimal.. Is there an place in VB6 where i can disable this? or do i have to do it programmatically? Even if i declare a variable of type double...example...

Dim value1 as double

value1 = 35.45 * 34 ( there is no problem at this point, it gives the exact value based on the computation)

text1.text = value1 ( at this point it is still ok, but after losing focus from the text1.text, it changes the value)

Round Off the textbox value after focus

only i can suggest about that if your textbox was bound in the datasource only you can do is look for your database table and find the fieldname you working for then change the (data type into number and its field size into integer) not single or double so it will automatically round off in the nearest value of your entry so if your entry was 648.33 it will become 648 after focus and if your entry was 456.99 it will become 457 try this settings of data type and field size in your database and observe what is the result okey!

N/A

N/A

The fact that the textbox is

The fact that the textbox is a BOUND control is your issue. I'd be willing to bet that the field that it's bound to is an "integer" field. In order to change this, you need to do one of two things:

Change the recordset's field to a Datatype "Double"

**OR**

If you're querying a database and then binding the control to the textbox, then you need to change the design of the table in your database. Change the field to a type decimal (in a SQL database).

HTH

Chewdoggie

Rounding off

I'm not sure what you mean rounding off, can you give an example?

Keith
www.martin2k.co.uk/forums/

I've been programming with VB for 12 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.