Solved

String format in VB.Net

Posted on 2011-09-06
4
233 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
Comment Utility
try
Dim Result = String.Format(szHoldFormat, szNumberString)

Open in new window

0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
0
 
LVL 74

Expert Comment

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

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

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

10 Experts available now in Live!

Get 1:1 Help Now