Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Equation Miscaculation


Hi there
When I put this formating to the value of TextBoxs,


Code:
--------------------
Gtot.Value = Format(Gtot.Value, "#,##0.000")
tot.Value = Format(tot.Value, "#,##0.000")
bal.Value = Format(bal.Value, "#,##0.000")
--------------------


Then the result of this line is always 1 or not correct

Code:
--------------------
bal.Value = val(Gtot.Value) - val(tot.Value)
--------------------


How can get the correct result out of equation ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486844

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Equation Miscaculation

from the immediate window:
? val("10,000")
10
? cdbl("10,000")
10000

so you might want to use cdbl instead of Val.

--
Regards,
Tom Ogilvy

"helmekki" wrote in
message ...

Hi there
When I put this formating to the value of TextBoxs,


Code:
--------------------
Gtot.Value = Format(Gtot.Value, "#,##0.000")
tot.Value = Format(tot.Value, "#,##0.000")
bal.Value = Format(bal.Value, "#,##0.000")
--------------------


Then the result of this line is always 1 or not correct

Code:
--------------------
bal.Value = val(Gtot.Value) - val(tot.Value)
--------------------


How can get the correct result out of equation ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:

http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486844



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Equation Miscaculation

You don't say where these objects are, but I tried textboxes on a userform
and it worked okay. What are the objects?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"helmekki" wrote in
message ...

Hi there
When I put this formating to the value of TextBoxs,


Code:
--------------------
Gtot.Value = Format(Gtot.Value, "#,##0.000")
tot.Value = Format(tot.Value, "#,##0.000")
bal.Value = Format(bal.Value, "#,##0.000")
--------------------


Then the result of this line is always 1 or not correct

Code:
--------------------
bal.Value = val(Gtot.Value) - val(tot.Value)
--------------------


How can get the correct result out of equation ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:

http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486844



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Equation Miscaculation


Thank u very much indeed..........

cdbl solved the problem and i now understand the difference between

val(10000) with format TextBox1.Value = Format(TextBox1.Value,
"#,##0.000")
appears as 10

and

CDbl(10000) with format TextBox1.Value = Format(TextBox1.Value,
"#,##0.000")
appears as 10,000.000


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486844

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with an equation Jeff Excel Discussion (Misc queries) 4 October 16th 08 10:00 PM
Equation Help sarah814 Excel Discussion (Misc queries) 2 June 16th 07 03:51 AM
Equation Editor- problem when editing an equation Gaby L. Excel Discussion (Misc queries) 0 September 27th 05 09:24 PM
Need help with equation mkerstei Excel Discussion (Misc queries) 1 August 4th 05 09:55 PM
Equation paulo_jorge_34 Excel Discussion (Misc queries) 3 June 14th 05 06:53 PM


All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"