How to do function that Left(String,int) in vb6?

  • Thread starter Thread starter mhw
  • Start date Start date
mhw said:
I don't found function!
Thanks£¡

Try substring.

string s = "Hello world";
string left5 = s.Substring( s.Length-5, 5 );
Console.WriteLine("S = {0}", left5 );

Output:

S = world

Matt
 
BUT ....
Subtstring will throw an exception if any of its arguments resolve to
indexes not within the string it is being applied to:

EXAMPLE
string s = "AB";
string left5 = s.Substring( s.Length-5, 5 ); <<<< throws exception
here




Try substring.

string s = "Hello world";
string left5 = s.Substring( s.Length-5, 5 );
Console.WriteLine("S = {0}", left5 );

Output:

S = world

Matt
 
Back
Top