?
Solved

Need help with formating a number

Posted on 2011-09-14
4
Medium Priority
?
268 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
[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 5

Expert Comment

by:Kenneth Brown
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 36

Accepted Solution

by:
Miguel Oz earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

800 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