ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format Question (https://www.excelbanter.com/excel-programming/353267-format-question.html)

Always Learning

Format Question
 
Hi Guys,



I may not have explained myself properly yesterday so I am re-posting hoping
this time I have explained a little better.



Can someone tell me why?



I have a form called "ResultsForm"

On that form I have a label called "SRWValueCalculated"

In my code I have "Dim TotalCost As Currency" which gets its value using
this bit of code:

"TotalCost = TotalCost + Cost4GoodRecs + Cost4BadRecs + Cost4DOBRecs"



The variables above, Cost4GoodRecs, Cost4BadRecs, Cost4DOBRecs are all
dimensioned as Currency



If I format the label Like so:

ResultsForm.SRWValueCalculated = Format(TotalCost, "###,##0.00")

If the value of TotalCost is 5,241.60 it displays as 5,241.60 which is fine,
but, if the value of TotalCost is 10,483.20 it

displays as 10,483.2 missing the final 0 (zero)



What is wrong?



As always, your help is appreciated.



Best Regards,



Steve.




Bernie Deitrick

Format Question
 
Steve,

It sounds like the label isn't wide enough to show that long of a number. Labels will simply
truncate long strings.

HTH,
Bernie
MS Excel MVP


"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
Hi Guys,



I may not have explained myself properly yesterday so I am re-posting hoping
this time I have explained a little better.



Can someone tell me why?



I have a form called "ResultsForm"

On that form I have a label called "SRWValueCalculated"

In my code I have "Dim TotalCost As Currency" which gets its value using
this bit of code:

"TotalCost = TotalCost + Cost4GoodRecs + Cost4BadRecs + Cost4DOBRecs"



The variables above, Cost4GoodRecs, Cost4BadRecs, Cost4DOBRecs are all
dimensioned as Currency



If I format the label Like so:

ResultsForm.SRWValueCalculated = Format(TotalCost, "###,##0.00")

If the value of TotalCost is 5,241.60 it displays as 5,241.60 which is fine,
but, if the value of TotalCost is 10,483.20 it

displays as 10,483.2 missing the final 0 (zero)



What is wrong?



As always, your help is appreciated.



Best Regards,



Steve.






Bob Phillips[_6_]

Format Question
 
The reason that you probably got no reply is because, like me, they cannot
replicate this behaviour. I see 10,4383.20 as expected.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
Hi Guys,



I may not have explained myself properly yesterday so I am re-posting

hoping
this time I have explained a little better.



Can someone tell me why?



I have a form called "ResultsForm"

On that form I have a label called "SRWValueCalculated"

In my code I have "Dim TotalCost As Currency" which gets its value using
this bit of code:

"TotalCost = TotalCost + Cost4GoodRecs + Cost4BadRecs + Cost4DOBRecs"



The variables above, Cost4GoodRecs, Cost4BadRecs, Cost4DOBRecs are all
dimensioned as Currency



If I format the label Like so:

ResultsForm.SRWValueCalculated = Format(TotalCost, "###,##0.00")

If the value of TotalCost is 5,241.60 it displays as 5,241.60 which is

fine,
but, if the value of TotalCost is 10,483.20 it

displays as 10,483.2 missing the final 0 (zero)



What is wrong?



As always, your help is appreciated.



Best Regards,



Steve.






Always Learning

Format Question
 
Hi Bob,
Thanks for the reply.

I hope you do not see 10,4383.20 (4 digits after the comma ?)

I know what you mean though, it's hard when someone else does exactly the
same and all is as it should be.
I have got around this by using text boxes instead of labels and all looks
good now.

Thanks for your help & time guys. It's appreciated.

Best Regards,

Steve Wilson.

"Bob Phillips" wrote in message
...
The reason that you probably got no reply is because, like me, they cannot
replicate this behaviour. I see 10,4383.20 as expected.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
Hi Guys,



I may not have explained myself properly yesterday so I am re-posting

hoping
this time I have explained a little better.



Can someone tell me why?



I have a form called "ResultsForm"

On that form I have a label called "SRWValueCalculated"

In my code I have "Dim TotalCost As Currency" which gets its value using
this bit of code:

"TotalCost = TotalCost + Cost4GoodRecs + Cost4BadRecs + Cost4DOBRecs"



The variables above, Cost4GoodRecs, Cost4BadRecs, Cost4DOBRecs are all
dimensioned as Currency



If I format the label Like so:

ResultsForm.SRWValueCalculated = Format(TotalCost, "###,##0.00")

If the value of TotalCost is 5,241.60 it displays as 5,241.60 which is

fine,
but, if the value of TotalCost is 10,483.20 it

displays as 10,483.2 missing the final 0 (zero)



What is wrong?



As always, your help is appreciated.



Best Regards,



Steve.








Bob Phillips[_6_]

Format Question
 
No it was a typo, only 3 digits.

Did you not see Bernie's answer, I was able to replicate the problem by
narrowing the label width. So I could show 5,241.60, but also only show
10,483.2. Solution was to just make it wider.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
Hi Bob,
Thanks for the reply.

I hope you do not see 10,4383.20 (4 digits after the comma ?)

I know what you mean though, it's hard when someone else does exactly the
same and all is as it should be.
I have got around this by using text boxes instead of labels and all looks
good now.

Thanks for your help & time guys. It's appreciated.

Best Regards,

Steve Wilson.

"Bob Phillips" wrote in message
...
The reason that you probably got no reply is because, like me, they

cannot
replicate this behaviour. I see 10,4383.20 as expected.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
Hi Guys,



I may not have explained myself properly yesterday so I am re-posting

hoping
this time I have explained a little better.



Can someone tell me why?



I have a form called "ResultsForm"

On that form I have a label called "SRWValueCalculated"

In my code I have "Dim TotalCost As Currency" which gets its value

using
this bit of code:

"TotalCost = TotalCost + Cost4GoodRecs + Cost4BadRecs +

Cost4DOBRecs"



The variables above, Cost4GoodRecs, Cost4BadRecs, Cost4DOBRecs are

all
dimensioned as Currency



If I format the label Like so:

ResultsForm.SRWValueCalculated = Format(TotalCost, "###,##0.00")

If the value of TotalCost is 5,241.60 it displays as 5,241.60 which is

fine,
but, if the value of TotalCost is 10,483.20 it

displays as 10,483.2 missing the final 0 (zero)



What is wrong?



As always, your help is appreciated.



Best Regards,



Steve.











All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com