Solved

String format in VB.Net

Posted on 2011-09-06
4
246 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

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

Suggested Solutions

Title # Comments Views Activity
MailAddress in vb 4 36
Get month and date in a format 4 45
VB.net Filesystem watcher not working 5 38
How can I add google maps in vb.net. 2 22
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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