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

Dear all;

I have a UserForm with a few textboxes.
The first textbox : tbAmount holds an invoice amount.
The second textbox: tbVAT should display the amount of VAT ( 19 %
of the amount )

The formula I use is: .tbVAT.Value = .tbAmount.Value * 0.19

Looks fine to me.
But, the stupid box don't disply the right amount.
I live in Europe and the Regional settings are a dot ( . ) for the thousands
seporator and a comma ( , ) for the decimal seporator.

When I enter 2250,00 ( or 2250 ) in .tbAmount, then textbox .tbVat displays
:
427.5 which is not what I want as I hope to see :
427,50

When I bring these values over to the worksheet it displays :
? 2250,00 which is OK, and
? 4275,00 which is not OK, as I want to see:
? 427,50

Apparantly there is some error in the way the textboxes work with thousands.
What is wrong with me ???? ( assuming I am not perfect )
I can't see what I did wrong.

Mark.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Calculating with textboxes....

Mark Rosenkrantz wrote:
Dear all;

I have a UserForm with a few textboxes.
The first textbox : tbAmount holds an invoice amount.
The second textbox: tbVAT should display the amount of VAT ( 19 %
of the amount )

The formula I use is: .tbVAT.Value = .tbAmount.Value * 0.19

Try:

..tbVAT.Value = FormatNumber(.tbAmount.Value * 0.19,2)


--
Steve Garman

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Calculating with textboxes....

Hi Mark

Don't trust a textbox's value property. Convert its text to number before calculation:

Sub test()
MsgBox CDbl("1.234,56")
End Sub

Dim R As Double
R = CDbl(.tbAmount.Text) * 0.19
..tbVat.Text = Format(R, "#,###.##")

Note that Format and VBA calculations use the american logic , for thousands and . for
decimals. You'll get used to it after a while.

-
HTH. Best wishes Harald
Followup to newsgroup only please.

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a UserForm with a few textboxes.
The first textbox : tbAmount holds an invoice amount.
The second textbox: tbVAT should display the amount of VAT ( 19 %
of the amount )

The formula I use is: .tbVAT.Value = .tbAmount.Value * 0.19

Looks fine to me.
But, the stupid box don't disply the right amount.
I live in Europe and the Regional settings are a dot ( . ) for the thousands
seporator and a comma ( , ) for the decimal seporator.

When I enter 2250,00 ( or 2250 ) in .tbAmount, then textbox .tbVat displays
:
427.5 which is not what I want as I hope to see :
427,50

When I bring these values over to the worksheet it displays :
? 2250,00 which is OK, and
? 4275,00 which is not OK, as I want to see:
? 427,50

Apparantly there is some error in the way the textboxes work with thousands.
What is wrong with me ???? ( assuming I am not perfect )
I can't see what I did wrong.

Mark.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Calculating with textboxes....

Thanks Harald and Steve.



"Harald Staff" wrote in message
...
Hi Mark

Don't trust a textbox's value property. Convert its text to number before

calculation:

Sub test()
MsgBox CDbl("1.234,56")
End Sub

Dim R As Double
R = CDbl(.tbAmount.Text) * 0.19
.tbVat.Text = Format(R, "#,###.##")

Note that Format and VBA calculations use the american logic , for

thousands and . for
decimals. You'll get used to it after a while.

-
HTH. Best wishes Harald
Followup to newsgroup only please.

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a UserForm with a few textboxes.
The first textbox : tbAmount holds an invoice amount.
The second textbox: tbVAT should display the amount of VAT (

19 %
of the amount )

The formula I use is: .tbVAT.Value = .tbAmount.Value * 0.19

Looks fine to me.
But, the stupid box don't disply the right amount.
I live in Europe and the Regional settings are a dot ( . ) for the

thousands
seporator and a comma ( , ) for the decimal seporator.

When I enter 2250,00 ( or 2250 ) in .tbAmount, then textbox .tbVat

displays
:
427.5 which is not what I want as I hope to see :
427,50

When I bring these values over to the worksheet it displays :
? 2250,00 which is OK, and
? 4275,00 which is not OK, as I want to see:
? 427,50

Apparantly there is some error in the way the textboxes work with

thousands.
What is wrong with me ???? ( assuming I am not perfect )
I can't see what I did wrong.

Mark.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Calculating with textboxes....

Actually 'in Europe' we do not all use commas as decimal seperators!!!

The term decimal point - should be just that. I suppose you'll be using
commas for full stops next!!

Only joking - I hope you fix the problem. I find that storing the values in
variables and assigning these to the control value is a far better method to
apply calculations. You have more control them this way.

Cheers
N
UK Origin

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a UserForm with a few textboxes.
The first textbox : tbAmount holds an invoice amount.
The second textbox: tbVAT should display the amount of VAT ( 19

%
of the amount )

The formula I use is: .tbVAT.Value = .tbAmount.Value * 0.19

Looks fine to me.
But, the stupid box don't disply the right amount.
I live in Europe and the Regional settings are a dot ( . ) for the

thousands
seporator and a comma ( , ) for the decimal seporator.

When I enter 2250,00 ( or 2250 ) in .tbAmount, then textbox .tbVat

displays
:
427.5 which is not what I want as I hope to see :
427,50

When I bring these values over to the worksheet it displays :
? 2250,00 which is OK, and
? 4275,00 which is not OK, as I want to see:
? 427,50

Apparantly there is some error in the way the textboxes work with

thousands.
What is wrong with me ???? ( assuming I am not perfect )
I can't see what I did wrong.

Mark.






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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
working with textboxes-VBA zxc[_2_] New Users to Excel 0 June 2nd 10 07:38 AM
Textboxes SAL Excel Discussion (Misc queries) 2 July 13th 07 12:24 AM
UserForm TextBoxes Rob Excel Discussion (Misc queries) 2 August 6th 05 03:07 AM
tab between several textboxes Kim Excel Worksheet Functions 0 May 9th 05 04:08 PM
Userfrom textboxes Jo[_6_] Excel Programming 2 October 21st 03 06:56 PM


All times are GMT +1. The time now is 03:38 AM.

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

About Us

"It's about Microsoft Excel"