Solved

String format in VB.Net

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET HttpWebRequest 12 58
Closing all open child forms. 4 38
Help with distributing .NET Framework with Clickonce technology 2 30
update textboxes with Streamreader 21 42
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now