QUOTE(andiyuniar @ 22 Aug, 2008 - 12:50 AM)

hi there...
i want to get the leftmost character from string.
i use this code
CODE
using Microsoft.VisualBasic;
tgllhr = Left(dr[2].ToString(),10);
but it did'nt work...
Any idea... how to solve this?
thanks
You may need to fully qualify the Left() method call if you are using it in a
class (form) that also has a Left property:
csharp
tgllhr = Microsoft.VisualBasic.Strings.Left(dr[2].ToString(),10);
The Left() method does not throw errors. The user is supposed to use the Len()
function to be sure the Left() method will return the desired substring. So if your
dr[2].ToString() is returning a null string Left() won't complain.
Another way to do what you want is to use the Substring() method of the System
namespace's String Class:
csharp
using System;
string tgllhr;
try
{
tgllhr = dr[2].ToString().Substring(0,10);
}
catch (ArgumentOutOfRangeException e) {
Console.WriteLine(e.Message);
}