Click here to Skip to main content
16,005,374 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Listview multiline Pin
Manas Bhardwaj28-Aug-08 5:15
professionalManas Bhardwaj28-Aug-08 5:15 
GeneralRe: Listview multiline Pin
Jon_Boy28-Aug-08 5:24
Jon_Boy28-Aug-08 5:24 
GeneralRe: Listview multiline Pin
JR21229-Aug-08 7:28
JR21229-Aug-08 7:28 
QuestionHow to format alpha-numeric strings? Pin
Jon_Boy28-Aug-08 2:27
Jon_Boy28-Aug-08 2:27 
AnswerRe: How to format alpha-numeric strings? Pin
Tim Carmichael28-Aug-08 3:40
Tim Carmichael28-Aug-08 3:40 
GeneralRe: How to format alpha-numeric strings? Pin
Jon_Boy28-Aug-08 4:04
Jon_Boy28-Aug-08 4:04 
AnswerRe: How to format alpha-numeric strings? Pin
Jon_Boy28-Aug-08 5:50
Jon_Boy28-Aug-08 5:50 
AnswerRe: How to format alpha-numeric strings? [modified] Pin
Guffa28-Aug-08 7:29
Guffa28-Aug-08 7:29 
The most efficient way, I think, is to use a StringBuilder:
Dim formatted As String = New StringBuilder(10) _
   .Append(alphaNumeric.Chars(0)) _
   .Append(alphaNumeric.Chars(1)) _
   .Append('-') _
   .Append(alphaNumeric.Chars(2)) _
   .Append(alphaNumeric.Chars(3)) _
   .Append(alphaNumeric.Chars(4)) _
   .Append(alphaNumeric.Chars(5)) _
   .Append('-') _
   .Append(alphaNumeric.Chars(6)) _
   .Append(alphaNumeric.Chars(7)) _
   .ToString()

The StringBuilder uses an internal string buffer, and the ToString method will return that buffer as a regular string, so there is no extra copying going on. As you define the correct size when creating the StringBuilder, there will be no reallocation of the buffer or unused overhead at the end of the string.

Another method is to use a regular expression. It's not as efficient, but fairly short:
Dim formatted As String = Regex.Replace(alphaNumeric, "(.{2})(.{4})(.{2})", "$1-$2-$3")


Despite everything, the person most likely to be fooling you next is yourself.

modified on Thursday, August 28, 2008 5:15 PM

GeneralRe: How to format alpha-numeric strings? Pin
Jon_Boy28-Aug-08 8:09
Jon_Boy28-Aug-08 8:09 
QuestionNo one can kill Windows service process Pin
nitin_ion28-Aug-08 1:54
nitin_ion28-Aug-08 1:54 
AnswerRe: No one can kill Windows service process Pin
jzonthemtn28-Aug-08 3:49
jzonthemtn28-Aug-08 3:49 
AnswerRe: No one can kill Windows service process [modified] Pin
Chinners28-Aug-08 4:26
Chinners28-Aug-08 4:26 
GeneralRe: No one can kill Windows service process Pin
nitin_ion1-Sep-08 18:08
nitin_ion1-Sep-08 18:08 
Questiondisplay data into datagrid Pin
anirai27-Aug-08 20:59
anirai27-Aug-08 20:59 
AnswerRe: display data into datagrid Pin
Vimalsoft(Pty) Ltd27-Aug-08 23:09
professionalVimalsoft(Pty) Ltd27-Aug-08 23:09 
Questionproblem while trying to insert number of rows into the database using dataset and tablemapping Pin
kisran27-Aug-08 19:56
kisran27-Aug-08 19:56 
Questionvb.net datagrid cell merging Pin
mmel_g27-Aug-08 19:51
mmel_g27-Aug-08 19:51 
AnswerRe: vb.net datagrid cell merging Pin
Ashfield27-Aug-08 21:15
Ashfield27-Aug-08 21:15 
GeneralRe: vb.net datagrid cell merging Pin
mmel_g29-Aug-08 16:03
mmel_g29-Aug-08 16:03 
QuestionHow to suppress javascript error while using WebClient Pin
MAP Tiger27-Aug-08 14:00
MAP Tiger27-Aug-08 14:00 
AnswerRe: How to suppress javascript error while using WebClient Pin
N a v a n e e t h27-Aug-08 19:47
N a v a n e e t h27-Aug-08 19:47 
GeneralRe: How to suppress javascript error while using WebClient Pin
MAP Tiger27-Aug-08 22:37
MAP Tiger27-Aug-08 22:37 
AnswerRe: How to suppress javascript error while using WebClient Pin
MAP Tiger28-Aug-08 0:02
MAP Tiger28-Aug-08 0:02 
GeneralRe: How to suppress javascript error while using WebClient Pin
dennisa29-Sep-09 13:32
dennisa29-Sep-09 13:32 
Questionvb.net and SQL server 2005 Pin
Rafone27-Aug-08 11:59
Rafone27-Aug-08 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.