How do I pass an array of strings from VB6 to .NET?
-
Hi, I build a .NET COM class that has a method (Print) with some parameters: .NET Code: Class Print Public Function DoPrint( _ ByVal PDFPath As String, _ ByVal PDFName As String, _ ByVal Printer As String, _ ByVal sSQLCol() As String) VB6 Code: dim cPrint as New Print.DoPrint Dim stringSQL1, stringSQL2 as String Dim SQLArray() As String stringSQL1= "SELECET * FROM TABLE1" stringSQL2 = "SELECT * FROM TABLE2" SQLArray(0) = stringSQL1 SQLArray(1) = stringSQL2 cPrint.Print(pdfpath, pdfname, printer, SQLArray) When I try to compile the VB6 app it gives me the following error: "Function or interface marked as restricted, or function uses an Automation type not supported in Visual Basic" How can I do this? Many thanks in advanced. Pedro
-
Hi, I build a .NET COM class that has a method (Print) with some parameters: .NET Code: Class Print Public Function DoPrint( _ ByVal PDFPath As String, _ ByVal PDFName As String, _ ByVal Printer As String, _ ByVal sSQLCol() As String) VB6 Code: dim cPrint as New Print.DoPrint Dim stringSQL1, stringSQL2 as String Dim SQLArray() As String stringSQL1= "SELECET * FROM TABLE1" stringSQL2 = "SELECT * FROM TABLE2" SQLArray(0) = stringSQL1 SQLArray(1) = stringSQL2 cPrint.Print(pdfpath, pdfname, printer, SQLArray) When I try to compile the VB6 app it gives me the following error: "Function or interface marked as restricted, or function uses an Automation type not supported in Visual Basic" How can I do this? Many thanks in advanced. Pedro
ordepavlis wrote: Class Print Public Function DoPrint .... dim cPrint as New Print.DoPrint I didn't know you could initialize a variable to a method ( DoPrint is a method). Perhaps that's where the error is?? Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
ordepavlis wrote: Class Print Public Function DoPrint .... dim cPrint as New Print.DoPrint I didn't know you could initialize a variable to a method ( DoPrint is a method). Perhaps that's where the error is?? Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark TwainHi, Sorry, You are rigth!! I copied the code badly. :zzz: So here it is the correct code: .NET: dll Name -> Print Class Name -> CReport Method -> DoPrint VB6: dim cPrint as New Print.CReport Thanks Pedro
-
Hi, Sorry, You are rigth!! I copied the code badly. :zzz: So here it is the correct code: .NET: dll Name -> Print Class Name -> CReport Method -> DoPrint VB6: dim cPrint as New Print.CReport Thanks Pedro
ordepavlis wrote: Dim stringSQL1, stringSQL2 as String Perhaps it's this part. When do this in vb6, stringSQL1 is dimensioned as a variant datatype. So you're actually passing variant when you're supposed to be passing string. You should declare it like this
Dim stringSQL1 as string, stringSQL2 as string
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
ordepavlis wrote: Dim stringSQL1, stringSQL2 as String Perhaps it's this part. When do this in vb6, stringSQL1 is dimensioned as a variant datatype. So you're actually passing variant when you're supposed to be passing string. You should declare it like this
Dim stringSQL1 as string, stringSQL2 as string
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark TwainHi, It gives me the same error. Pedro