Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How do I pass an array of strings from VB6 to .NET?

How do I pass an array of strings from VB6 to .NET?

Scheduled Pinned Locked Moved Visual Basic
questioncsharpcomdata-structures
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ordepavlis
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • O ordepavlis

      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

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      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

      O 1 Reply Last reply
      0
      • N Nick Seng

        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

        O Offline
        O Offline
        ordepavlis
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • O ordepavlis

          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

          N Offline
          N Offline
          Nick Seng
          wrote on last edited by
          #4

          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

          O 1 Reply Last reply
          0
          • N Nick Seng

            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

            O Offline
            O Offline
            ordepavlis
            wrote on last edited by
            #5

            Hi, It gives me the same error. Pedro

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups