Solved

Need help with formating a number

Posted on 2011-09-14
4
267 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

688 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