Results 1 to 4 of 4

Thread: how to use byref on vbs,vb6 call com method?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    how to use byref on vbs,vb6 call com method?

    how to use VBS_Call_Sum_Click with byref?

    Code:
    Public Function Sum(ByVal a As Long, ByRef B As Long) As Long 'method=447
        MsgBox ("Form1 sum Called?arg a,b=" & a & "," & B)
        Sum = a + B
        B = B * 2
    End Function
    Public Function Sum2(ByVal a As Long, ByVal B As Long) As Long 'method=447
        MsgBox ("Form1 sum2 Called?arg a,b=" & a & "," & B)
        Sum2 = a + B
        B = B * 2 
    End Function
    
    Private Sub VBS_Call_Sum_Click() 'err
    Dim vbs As New ScriptControl
        vbs.Language = "vbs"
         
        vbs.AddObject "Form1", Me, True
        vbs.AddCode "dim a,b,c:a=3:b=clng(4):c=0"
        vbs.AddCode "c=Form1.sum(a,b)"
        vbs.AddCode "msgbox c"
        vbs.AddCode "msgbox ""b="" & b" 'b=2*b
    End Sub
    
    Private Sub VBS_Call_Sum2_Click()
    Dim vbs As New ScriptControl
    vbs.Language = "vbs"
     
    vbs.AddObject "Form1", Me, True
    vbs.AddCode "dim a,b,c:a=3:b=4:c=0"
    vbs.AddCode "c=Form1.sum2(a,b)"
    vbs.AddCode "msgbox c"
    vbs.AddCode "msgbox ""b="" & b"
    
    End Sub
    Attached Files Attached Files
    Last edited by xiaoyao; Jun 17th, 2024 at 09:13 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    Re: how to use byref on vbs,vb6 call com method?

    Code:
    Private Sub Command1_Click()
        'CallCom_DispCallFunc
     
        Dim a As Long, B As Long, C As Long
        Dim A1 As Long, B1 As Long
        a = 3
        B = 4
        A1 = a
        B1 = B
     
         Call CallCom(ObjPtr(Me), 447, a, VarPtr(B), VarPtr(C))
        
        MsgBox "OLD_a=" & A1 & ",OLD_b=" & B1 & ",C=" & C & ",Now b=" & B
        
        MsgBox "how to call com with DispCallFunc api ,on vbs?" & vbCrLf & ",vbs can't support as long/VarPtr?how to do?"
    End Sub

  3. #3
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,099

    Re: how to use byref on vbs,vb6 call com method?

    Should you really be writing new VBScript when Microsoft is removing it over the next couple years?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    Re: how to use byref on vbs,vb6 call com method?

    i will run vbs on wine,windows run wine,linux wine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width