Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a variable length string that I need to manipulate.

 

It's 20+ characters long, but I only need the first 3 and second three for

example:

 

abcdef 12.5,.76m4---L7,8724...

 

I can get the strip out all but first three (ABC) , and shift them to upper case, but can't find a method to extract the second three or the characters def.

 

Here's my code:

 

str1 = (str1.ToUpper)

trimmedString = (str1.Remove(3))

 

Any ideas?

 

 

 

Thanks,

 

Gary

Posted

I'm not entirely sure I've understood what your trying to achieve. Assuming I've understood you at least partially correctly the Method you would need is the SubString() method.

Dim str As String = "abc123alskdfjlasdkfj;kl"
Dim fstThree As String = str.Substring(0, 3)
' fstThree would be abc
Dim secThree As String = str.Substring(3, 3)
' secThree would be 123

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...