Click here to Skip to main content
15,913,587 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have these machine names at work that has its location in the 3456 letter our of 10 or 12 letters. I have been searching google for how to split a string but havent found what im looking for to make this work.

the machine names look like this DDXXXX000000 now i need to get the XXXX value. help would be great or if someone can point me in the right direction that would be great.
Posted

What's wrong with System.String.Split or System.String.Substring? Did you see
http://msdn.microsoft.com/en-us/library/system.string.aspx[^]?

—SA
 
Share this answer
 
Comments
Zachary.shupp 5-Apr-12 21:23pm    
Im just not understanding how to get those 4 from it. could your provide and example?
Sergey Alexandrovich Kryukov 6-Apr-12 1:16am    
"Just"? Was that the reason for not reading the MSDN article? Your original question was already the abuse...
--SA
Manoj K Bhoir 6-Apr-12 0:08am    
Just Write Following Code :

MessageBox.Show("DDXXXX000000".SubString(2,4))
Sergey Alexandrovich Kryukov 6-Apr-12 1:17am    
Thank you, Manoj.
--SA
Use Substring method of string class to get the required sub string as shown below
VB
Sub Main
    Dim MachineName as string = "DDXXXX000000"
    Dim Location as String = MachineName.Substring(2,4)
    Console.WriteLine(Location)
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900