473,574 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting problem

I guess I still have not grasped the logic of formatting a simple label or
text box.

Why would the following not work? I need the resulting label to display
currency.

lblAmtDue.Text = CInt(txtEntries .Text) * 1.5

lblAmtDue.Text. Format("$#,##0. 00")
Nov 21 '05 #1
6 1331
"Brad" <ba******@ukcdo gs.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I guess I still have not grasped the logic of formatting a simple label or
text box. .. . . lblAmtDue.Text = CInt(txtEntries .Text) * 1.5

lblAmtDue.Text. Format("$#,##0. 00")


This is what VB will effective do...

lblAmtDue.Text = ( CInt(txtEntries .Text) * 1.5 ).ToString()

Call lblAmtDue.Text. Format("$#,##0. 00")

I think what you need is

lblAmtDue.Text = ( CInt( txtEntries.Text ) * 1.5 ).ToString("$#, ##0.00")

and I'd /strongly/ recommend adding

Option Strict On

either as a Project [default] setting or at the top of the Module.

HTH,
Phill W.
Nov 21 '05 #2
Try the Format function...

lblAmtDue.Text = Format(CInt(txt Entries.Text) * 1.5, "$#,##0.00" )

or better yet

use FormatCurrency function

Greg

"Brad" <ba******@ukcdo gs.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I guess I still have not grasped the logic of formatting a simple label or
text box.

Why would the following not work? I need the resulting label to display
currency.

lblAmtDue.Text = CInt(txtEntries .Text) * 1.5

lblAmtDue.Text. Format("$#,##0. 00")

Nov 21 '05 #3
Apply formatting on the integer itself.

lblAmtDue.Text = (CInt(txtEntrie s.Text) * 1.5).ToString(" $#,##0.00")

"Brad" <ba******@ukcdo gs.com> wrote in message
news:#1******** ******@tk2msftn gp13.phx.gbl...
I guess I still have not grasped the logic of formatting a simple label or
text box.

Why would the following not work? I need the resulting label to display
currency.

lblAmtDue.Text = CInt(txtEntries .Text) * 1.5

lblAmtDue.Text. Format("$#,##0. 00")

Nov 21 '05 #4
* "Brad" <ba******@ukcdo gs.com> scripsit:
Why would the following not work? I need the resulting label to display
currency.


..NET Framework Developer's Guide -- Standard Numeric Format Strings
<URL:http://msdn.microsoft. com/library/en-us/cpguide/html/cpconStandardNu mericFormatStri ngs.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
Brad,
As the others have suggested, Text.Format is a function that returns a value
that is formatted, you are ignoring that value.

Rather then hard code the format to US dollars, I would use "C" a standard
format specifier for currency in region you are in.

I would recommend something like:

lblAmtDue.Text = (CInt(txtEntrie s.Text) * 1.5).ToString(" C")

Which says take the integer value of txtEntries.Text , multiply that by 1.5,
convert the result of the multiplication to a string using the currency
format, then assign this formatted string to the Text property of lblAmtDue.

For details on Formatting in .NET see:

http://msdn.microsoft.com/library/de...ngoverview.asp

For standard numeric format strings (such as "C") see:

http://msdn.microsoft.com/library/de...matstrings.asp
I would also strongly recommend you include Option Strict On at the top of
your source files to avoid implicit conversions from Double to Text.

Hope this helps
Jay

"Brad" <ba******@ukcdo gs.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I guess I still have not grasped the logic of formatting a simple label or
text box.

Why would the following not work? I need the resulting label to display
currency.

lblAmtDue.Text = CInt(txtEntries .Text) * 1.5

lblAmtDue.Text. Format("$#,##0. 00")

Nov 21 '05 #6
Hi Brad,

Because Greg is all alone in this thread, I find this one real very nice

txtEntries.Text = FormatCurrency( CDec(txtEntries .Text)* 1.5)

Cor
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5924
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both...
4
4140
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I want all of the controls in whatever is the CURRENT record to have it's data bolded on the screen. (Question #1: Is there a SIMPLE way to refer to...
8
3503
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word...
2
1190
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold when the date has passed. Background: I have 2 related fields that are only rarely active, so I manage them in the query for the subform:...
10
3148
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim ld_tot_pet_clean_fee_calc As Double ld_tot_pet_clean_fee_calc = li_net_total_calc * 0.0075 ld_tot_pet_clean_fee = lo_misc_func.FormatMC(ld_tot_pet_clean_fee_calc,...
8
1770
by: gopal | last post by:
Hi I am trying to write to log file but the formatting of string is not properly aligned in log file result The results looks some thing like this OK move.xml Successful OK AppUser_ifrUsers.asp Successful
8
8472
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional...
14
4291
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my unformatted data values (as decimals) just fine, so I know there's not a problem with the data retrieval, just the formatting. I have read that this...
10
2117
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF (using ConvertReportToPDF from this site - Stephan Lebans) The formatting - Outlines on some fields - do not appear on subreports
6
4581
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
0
7755
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8097
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6504
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5333
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3770
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2268
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1097
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.