473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

string formatting

hey all,
how do i take a string like "123456789"
and format it like this: "123-45-6789"

thanks,
rodchar
Apr 13 '06 #1
5 4883

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
how do i take a string like "123456789"
and format it like this: "123-45-6789"


Should be something like Format$("123456789", "###-##-####")

Note that if this is a SSN it is a string, not a number.
Apr 13 '06 #2

Try Format("123456789","@@@-@@-@@@@")

Apr 14 '06 #3

<St*********@EagleCCI.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...

Try Format("123456789","@@@-@@-@@@@")


That works in VB6 but they've dumped it in VB .Net. It's an SOB to find the
replacement.

Apr 14 '06 #4

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
hey all,
how do i take a string like "123456789"
and format it like this: "123-45-6789"


Dim S As String = "123456789"
If Len(S) = 9 Then S = Mid(S, 1, 3) & "-" & Mid(S, 4, 2) & "-" & Mid(S, 6,
4)
Apr 14 '06 #5
thanks everyone.

"rodchar" wrote:
hey all,
how do i take a string like "123456789"
and format it like this: "123-45-6789"

thanks,
rodchar

Apr 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Thomas Philips | last post by:
Consider the following simple dictionary e={1:'one', 2: 'two'} e >>>'one' However, If I attempt to print e using a formatted string print " %(1)s" %e, I get a KeyError: '1'
10
by: Oliver S. | last post by:
I've developed a string-class that holds the string in an array which is a member-variable of the class and that has maximum-size which is con- figurable through a template-parameter. If any...
20
by: hagai26 | last post by:
I am looking for the best and efficient way to replace the first word in a str, like this: "aa to become" -> "/aa/ to become" I know I can use spilt and than join them but I can also use regular...
5
by: Andrew Connell | last post by:
Having fits transforming an XML string using an XSL file. In the 1.1 version of the framework, I see that the XmlResolver is heavily used in the XslTransform class. However, that looks like I am...
4
by: Dennis Myrén | last post by:
Hi. Is there a way to utilize the great primitive data type formatting routines available in .NET without working with strings? I want a byte directly rather than a string. I think it is...
7
by: ilona | last post by:
Hi all, I store phone numbers in the database as 123447775665554(input mask is used for input, and some numbers have extensions), and I also know from db if the number is Canadian, US, or some...
7
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
1
by: schoedl | last post by:
Hello, we often compose strings via a ostringstream and then create a string from it. What is the rationale of not being able to use string in place of a ostringstream, so I could write ...
6
by: Jack | last post by:
Hi there, Given a standard .NET string, does anyone know what the regular expression would be to locate each (optional) formatting item in the string (or more likely does anyone have a link that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.