Solved

String format in VB.Net

Posted on 2011-09-06
4
238 Views
Last Modified: 2012-08-13
I am migrating an application from VB6 to VB.Net...

In VB6, the previous team used the following function:
Format(szNumberString,szHoldFormat)
szNumberString is string which has numbers and which needs to be formatted.
szHoldFormat is string which holds the format that needs to be implemented.szHoldFormat is build on basis of szNumberString and how many digits it has.

The upgrade converted the code to the following function:
VB6.Format (szNumberString,szHoldFormat)

When I use :
String.Format ("{0:szHoldFormat}", szNumberString)
The value returned to me is the string stored in szHoldFormat and not the formatted string.

I am looking to get the string formats as outputs in my labels/text boxes.
For eg. if szNumberString= 20 then value for szHoldFormat = "##.00" the output should be 20.00 but i get an output as "##.00"

Could you please help me with this?
0
Comment
Question by:vijethbalaram
4 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 36488198
try
Dim Result = String.Format(szHoldFormat, szNumberString)

Open in new window

0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36488215
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36488485
Try this:
szHoldFormat = String.Concat("{0:", szHoldFormat, "}")

Dim result As String = String.Format (szHoldFormat, szNumberString)

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question