string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have many strings
x= xxxxxxxxxxxxxx[284}
y=yyyyy[0]
z=zzzzzzzzzzzzzz[60]

I need to read the number in [] and save as an integer..
what is the best way to do that???
 
Lamis said:
Hi,

I have many strings
x= xxxxxxxxxxxxxx[284}
y=yyyyy[0]
z=zzzzzzzzzzzzzz[60]

I need to read the number in [] and save as an integer.. what is the
best way to do that???


If "]" is always the last char:


Dim s As String = "xxxxxxxx[284]"
Dim p As Integer
Dim i As Integer

p = s.LastIndexOf("["c, s.Length - 2)
i = Integer.Parse(s.Substring(p + 1, s.Length - p - 2))




Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top