Solved

Need help with formating a number

Posted on 2011-09-14
4
258 Views
Last Modified: 2013-11-07
I need to format an 11 digit number like this 999-999-99-999 and display it in a label.  The formatting is just for display purposes. The number is stored without the dashes in the database. I've tried using String.Format but haven't had much luck. Any ideas?
0
Comment
Question by:EDCTECH
4 Comments
 
LVL 5

Expert Comment

by:KenIBrown2
ID: 36539912
Write some code to split your 11 digit string into 4 sep strings
abc-def-gh-ijk -> s1,s2,s3,s4
use the string.mid function (in vb)
http://msdn.microsoft.com/en-us/library/aa903372(VS.71).aspx

then use string.format on those, adding dashes as necc.
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 36539924
0
 
LVL 40
ID: 36539962
You probably had problem with String.Format becauce you do not know of the backlash trick. When you want to force a specific character in the format, but a backslash in front of it:

String.format("{0:###\-###\-##\-###}",99999999999)
0
 

Author Closing Comment

by:EDCTECH
ID: 36540002
Thanks!  That is what I needed.

  Dim strSelectedParcel As String = String.Format("{0}-{1}-{2}-{3}", _
               btnTemp.Text.Substring(0, 3), _
                btnTemp.Text.Substring(3, 3), _
                btnTemp.Text.Substring(6, 2), _
                btnTemp.Text.Substring(8, 3))
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

708 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

18 Experts available now in Live!

Get 1:1 Help Now