Hi Hitesh,
My code extract data from the mshtml.HTMLElement
string value;
mshtml.IHTMLDocument2 doc;
mshtml.IHTMLElementCollection tbls = (mshtml.IHTMLElementCollection)
((mshtml.IHTMLElementCollection) doc.body.all).tags("table");
mshtml.HTMLTable tbl = (mshtml.HTMLTable) tbls.item(1,1);
mshtml.HTMLTableRow tblRow = (mshtml.HTMLTableRow) tbl.rows.item(1,1);
if (tblRow.cells != null)
{
mshtml.IHTMLElement tblElement = (mshtml.IHTMLElement)
tblRow.Cells.item(2,2);
value = tblElement.innerText;
// Error Occur Here!
if (value.Length > 0 && value != string.Empty){
value = value.Trim();
}
}
I think the problem occur when the innerText is Empty and I am trying to
trim the value.
Regards Dat.
(E-Mail Removed) wrote:
> Hi Dat,
>
>
> This code is working fine on my end and I am getting the expected
> output.Could u please more elobrate ur problem.
>
> Thanks,
> Hitesh
>
>
> Dat K. AU DUONG wrote:
>> Hi,
>>
>> C# Annoying string function or Am I doing Something wrong?
>>
>> In VB6/VB.NET I can code like:
>> value = value.trim()
>>
>> and it just work!
>>
>>
>> But in c#, I event put in the additional check I still get the error.
>> if (value.Length > 0 && value != string.Empty){
>> value = value.trim();
>> }
>>
>> The error message:
>> startIndex cannot be larger than length of string.
>> Parameter name: startIndex at
>> System.String.InternalSubStringWithChecks(Int32 startIndex, Int32
>> length, Boolean fAlwaysCopy) ...
>>
>> Please Help!
>> Thanks.
>> Regards Dat.
>