I receive some great information about executing the contents of a string using the EbExecuteLine function within the vba6.dll. But I am having a problem ... this seems to work great when testing within Visual Basic, but as soon I run the compiled version (.exe) it gives me a memory read error!!!

Has anyones else experience this? What am I doing wrong?? Please help.

Here is the test code I am running:

Public stRETURN As String * 256
Private Declare Function EbExecuteLine Lib "vba6.dll" ( _
ByVal stStringToExec As Long, _
ByVal Unknownn1 As Long, _
ByVal Unknownn2 As Long, _
ByVal fCheckOnly As Long) As Long


Private Sub Main()

If ExecuteLine("stRETURN = Space(256):stRETURN = Cstr(Now())") = False Then
Call MsgBox("IT FAILED!!")
Else
Call MsgBox("IT WORKED!! RETURN = " & stRETURN)
End If
End Sub

Private Function ExecuteLine(stCode As String, Optional bCheckOnly As Boolean = False) As Boolean
Dim stCommand As String * 256
Dim lgPtr As Long

stCommand = stCode
lgPtr = StrPtr(stCommand)
ExecuteLine = EbExecuteLine(lgPtr, 0&, 0&, Abs(bCheckOnly)) = 0
End Function

Any help would be greatly appreciated!!