473,746 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format string question

The following was copied from a web site for learning formatting.
Dim myInt As Integer = 100
Dim FormatPrice As String = String.Format(" Price = |{0,10:c }|", myInt)
Console.WriteLi ne(FormatPrice)
The result shown is no number but the character c as in the format string.
Is the format not valid in this context?

Thanks for your assistance,

Jul 21 '05 #1
1 1507
The format string should be "Price = |{0:c10}|" . This will give you:

Price = |$100.000000000 0|

in the console window if you are using the English (United States) as your
language . For more information on Standard Numeric Format Strings check


"ke************ *@state.or.us" <Ke************ ***@state.or.us > wrote in
message news:ek******** ******@TK2MSFTN GP10.phx.gbl...
The following was copied from a web site for learning formatting.
Dim myInt As Integer = 100
Dim FormatPrice As String = String.Format(" Price = |{0,10:c }|", myInt)
Console.WriteLi ne(FormatPrice)
The result shown is no number but the character c as in the format string.
Is the format not valid in this context?

Thanks for your assistance,

Jul 21 '05 #2

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

Similar topics

by: san | last post by:
Hello, all! I have question about String.Format method. There are two variants: public static string Format(string, params object); and public static string Format(IFormatProvider, string, params object); What happens if i will use String.Format("{0} and {1}", "one", "two") instead of String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} and {1}", "one", "two")?
by: Stuart McGraw | last post by:
I am looking for a VBA "format" or "template" function, that is, a function that takes a format string and a varying number of arguments, and substitutes the argument values into the format string as specified in the format string. For example fmt("this is $1 format string. arg2 is $2", "short", 3) would return the string "this is short format string. arg2 is 3" Now, the above is easy to write and I have done so. What I want is...
by: Roger Helliwell | last post by:
Hello Everyone, Has anyone found a quick reference for the many string formatting options for string.Format() ? I'm spending a ridiculous amount of time trying to write one line of code that would take about 3 seconds in C. (Sarcasm not intended.) All I need is a format string to zero pad an integer out to 9 digits.
by: Tommy Vercetti | last post by:
The first three of these statements work. The fourth doesn't. String::Format("{0}{0}{0}{0}", S""); String::Format("{0}{1}{0}{0}", S"", S""); String::Format("{0}{1}{2}{0}", S"", S"", S""); String::Format("{0}{1}{2}{3}", S"", S"", S"", S""); Question #1: Why? Question #2: What is the simplest way to get this to work. I would
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a date format of "mm/dd/yy" For example the barcode contains "112303" and I want to format it to display "11/23/03" If I use the microsoft.visualbasic.strings.format with a format string of "##/##/##" or "00/00/00" I get the format string in the...
by: gjuro kladaric | last post by:
hi there, I am just learning about IFormattable, ICustomFormatter, IFormatProvider and the like... although being a bit tricky to understand, it becomes clear after some clicking and readying... what is not clear to me and constitutes my question is:
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way to configure server, sql server or program so it always deals with date as mm/dd/yyyy format. Thanks in advance. Roy
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: CAST(O.MYDATE AS CHAR(30)) When directly updating date fields in the main table, the logged value gets saved in the format YYYY-MM-DD as expected.
by: Scewbedew | last post by:
Suppose I have the following code: string myFormat = "Line1/nLine 2"; string formattedString = string.Format(myFormat); ....that would produce a 2-line output as expected. But if I load that very same format string from an xml file: ....load xmlNode WorkNode...
by: Martin | last post by:
I'm retrieving some records from a database. One of the fields contains a date/time. I would like to format it as I send it out to the table in the displayed page. Can some one please tell me how I can/should do that? Or possibly point me to an on-line explanation? Thanks ps: if it makes any difference, the data is coming from a MS Access
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.