Solved

String format in VB.Net

Posted on 2011-09-06
4
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

690 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