Answered by:
conversion from c# to vb

Question
-
User-1661238708 posted
hi there,
i want to convert the following code from c# to vb.
ArrayList htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
the convertion tool gave me as a result:
Dim htmlarraylist As ArrayList = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText),Nothing)
the problem is that an error occurs
Error 5 Value of type 'System.Collections.Generic.List(Of iTextSharp.text.IElement)' cannot be converted to 'System.Collections.ArrayList'.
any i deas?
thanks
Friday, April 30, 2010 8:56 AM
Answers
-
User197322208 posted
Dim htmlarraylist As System.Collections.Generic.List(Of iTextSharp.text.IElement)= iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText),Nothing)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 30, 2010 9:07 AM
All replies
-
User197322208 posted
Dim htmlarraylist As System.Collections.Generic.List(Of iTextSharp.text.IElement)= iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText),Nothing)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 30, 2010 9:07 AM -
User-1661238708 posted
that was really embarasing...
thanks...
Friday, April 30, 2010 9:15 AM -
User-1661238708 posted
i am trying to create a pdf from html an i am using itextsharp like this:
PdfWriter.GetInstance(document, New FileStream(path, FileMode.Create)) Dim htmlArray As System.Collections.Generic.List(Of iTextSharp.text.IElement) = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlReport), Nothing) document.Open() For k = 0 To htmlArray.Count - 1 document.Add(htmlArray(k)) Next k document.Close()
now i am getting the following error:
Unable to cast object of type 'iTextSharp.text.html.simpleparser.IncCell' to type 'iTextSharp.text.Rectangle'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'iTextSharp.text.html.simpleparser.IncCell' to type 'iTextSharp.text.Rectangle'.
Source Error:
Line 113: For k = 0 To htmlArray.Count - 1 Line 114: Line 115: document.Add(htmlArray(k)) Line 116: Next k Line 117: document.Close()
any ideas ?
thanks
Friday, April 30, 2010 9:22 AM -
User197322208 posted
Unable to cast object of type 'iTextSharp.text.html.simpleparser.IncCell' to type 'iTextSharp.text.Rectangle'.This is more error prone. VB does not have type checking and it tries to cast . What are the relation between
'iTextSharp.text.html.simpleparser.IncCell' to type 'iTextSharp.text.Rectangle'
?
And I suggest you to move all the vb code in a dll, compile with VB and make methods to use from C#( that is, if the vb code works...)
Friday, April 30, 2010 9:38 AM