returning n left chars of a string

  • Thread starter Thread starter microsoft
  • Start date Start date
M

microsoft

Sorry. Maybe I'm too lazy here.
What is the code for returning all but the last character of a string?

In vb6:
s="12345"
s=left(s,len(s)-1)
's would now be "1234"

Seems like using s.substring would be involved....
 
microsoft said:
Sorry. Maybe I'm too lazy here.
What is the code for returning all but the last character of a string?

In vb6:
s="12345"
s=left(s,len(s)-1)
's would now be "1234"

Seems like using s.substring would be involved....

Yes, s.Substring (0, s.Length-1) will do it.
 
The s. was the clue I needed.

compactframework vb.net didn't like s.Left but the following trims the last
character from the string:

s = s.Remove(s.Length - 1, 1)
 
Sorry, was thinking about the different class:
s = Strings.Left(s, s.Length - 1)

Or do what John suggests.
 
Back
Top