Results 1 to 5 of 5

Thread: Executing a single line of VB Code

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Thumbs up

    I've seen it somewhere before;

    You can execute a line of VB code from a string somehow...

    Like: VBExecute("msgbox 'This is a user generated dialog'")
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    yeah i've seen someone put that code on the forums ... i'm pretty sure it was a guru or someone with at least 2000 posts ... so u should do a search for guru people

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Use the Microsoft Scripting Host. It comes with an activex control that you can use in vb. I don't remember how to use it, but it's something like controlname.execute.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  4. #4
    Guest
    Away with scipting.. Try this:

    Code:
    Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Foo1 As Long, ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long
    
    ' = = = =  For VB5
    'Declare Function EbExecuteLine Lib "vba5.dll"  (ByVal pStringToExec As Long, ByVal Foo1 As Long,  ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long
    
    ' = = = =  For Access 97/VBE.dll clients as Word 97 and Excel 97
    'Declare Function EbExecuteLine Lib "vba332.dll" (ByVal pStringToExec As Long, ByVal Foo1 As Long, ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long
    
    Function FExecuteCode(stCode As String, Optional fCheckOnly As Boolean) As Boolean
        FExecuteCode = EbExecuteLine(StrPtr(stCode), 0&, 0&, Abs(fCheckOnly)) = 0
    End Function
    
    Private Sub Form_Load()
        Dim TheString As String
        
        TheString = "MsgBox ""This is a user generated dialog"""
        Debug.Print FExecuteCode(TheString, False)
    End Sub
    Enjoy!

  5. #5

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