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. VBScript / JScript: out Parameter

VBScript / JScript: out Parameter

Scheduled Pinned Locked Moved Visual Basic
questionhelp
4 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.
  • R Offline
    R Offline
    Roland Bar
    wrote on last edited by
    #1

    Hi, i should use a Component in VBScript or JScript that has a Function with an out parameter. in VB I can use the Component like this: Dim myComponent As Component Set myComponent = New Component Dim res As Long Call myComponent.MyFunction(res, "some String", 1, 2, "another Text") If res <> 0 Then MsgBox ("Error while executing MyFunction") how can I write the VBScript of JScript code that the res variable is passed by reference and not by value, so i can check the value afterwards? Greets Roland

    D 2 Replies Last reply
    0
    • R Roland Bar

      Hi, i should use a Component in VBScript or JScript that has a Function with an out parameter. in VB I can use the Component like this: Dim myComponent As Component Set myComponent = New Component Dim res As Long Call myComponent.MyFunction(res, "some String", 1, 2, "another Text") If res <> 0 Then MsgBox ("Error while executing MyFunction") how can I write the VBScript of JScript code that the res variable is passed by reference and not by value, so i can check the value afterwards? Greets Roland

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Last I checked, VBScript doesn't support passing by reference. You can only pass by value. EDIT: My bad! Script 5.6 supports passing by reference. Checking into the problem though... RageInTheMachine9532

      1 Reply Last reply
      0
      • R Roland Bar

        Hi, i should use a Component in VBScript or JScript that has a Function with an out parameter. in VB I can use the Component like this: Dim myComponent As Component Set myComponent = New Component Dim res As Long Call myComponent.MyFunction(res, "some String", 1, 2, "another Text") If res <> 0 Then MsgBox ("Error while executing MyFunction") how can I write the VBScript of JScript code that the res variable is passed by reference and not by value, so i can check the value afterwards? Greets Roland

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        OK. When you write your component, all that you need to do is add ByRef to the declaration where 'res' is going to get passed in:

        Public Sub MyFunction(ByRef var1 As Integer, var2 As String, var3 As Integer)
        

        I verified that this does work between a VB6 ActiveX control and VBScript on Windows Script 5.6. RageInTheMachine9532

        R 1 Reply Last reply
        0
        • D Dave Kreskowiak

          OK. When you write your component, all that you need to do is add ByRef to the declaration where 'res' is going to get passed in:

          Public Sub MyFunction(ByRef var1 As Integer, var2 As String, var3 As Integer)
          

          I verified that this does work between a VB6 ActiveX control and VBScript on Windows Script 5.6. RageInTheMachine9532

          R Offline
          R Offline
          Roland Bar
          wrote on last edited by
          #4

          The Problem is: The Component was built with Visual C++ (ATL). The Parameter is declarated as [out] in the type library file, but I sgould be able to tell this the VBScript/JScript. Wit VBScript I get an compile error 'Type mismatch', with JScript it compiles but the Variable is not changed through the Component. I left this problem behind with writing a small C++ App that i call from the Script, but thanks for your help. Of course, if you have some idea, your input is still very welcome. Greets Roland

          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