I have a problem with the using of the addressof-operator in VBA / Access97.
Please see my little VBA-Module:
Option Compare Database
Option Explicit
Public Function Test()
MsgBox "Test"
End Function
Public Function Test1()
Dim addr As Long
addr = addressof Test
End Function
If I input »addressof« the programmers help show me a list of all functions, also
the function Test. But when I choose this entry and want to leave this line, the
line changes to read, and a messagebox with the error message »Fehler beim
Kompilieren - Erwartet: Ausdruck« (in Englisch: Error on Compilation - Expected:
expression) is showed.
If I try to compile the module, the same occurs. Can you help me?
In my opinion, in the variable addr must stored the address of the function test.
Thank you for your help
'Provides Callback functionality in VBA
'May be replaced with AddressOf function in future versions of VBA
'***Important***
'Callback function parameters must exactly match those expected by the API
'otherwise a GPF will result!
Private Declare Function GetAddr Lib "Vba332.dll" Alias "TipGetLpfnOfFunctionId"
(ByVal hProject As Long, ByVal strFunctionID As String, ByRef lpfn As Long) As Long
Private Declare Function GetFuncID Lib "Vba332.dll" Alias "TipGetFunctionId" (ByVal
hProject As Long, ByVal strFunctionName As String, ByRef strFunctionID As String) As
Long
Private Declare Function GetCurrentVBAProject Lib "Vba332.dll" Alias
"EbGetExecutingProj" (hProject As Long) As Long
Public Function AddrOf(strFuncName As String) As Long
Dim hProject As Long
Dim lngResult As Long
Dim strID As String
Dim lpfn As Long
Dim strFuncNameUnicode As String
Const NO_ERROR = 0
'The function name must be in Unicode
strFuncNameUnicode = StrConv(strFuncName, vbUnicode)
'Get the current VBA project handle
GetCurrentVBAProject hProject
If hProject <> 0 Then
lngResult = GetFuncID(hProject, strFuncNameUnicode, strID)
If lngResult = NO_ERROR Then
'Get the function pointer
lngResult = GetAddr(hProject, strID, lpfn)
If lngResult = NO_ERROR Then
AddrOf = lpfn
End If
End If
End If
End Function
Hope this helps
Tony Oakley
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
"Tony Oakley" <To...@nospam.softoak.demon.co.uk> wrote in message
news:3A5C4113...@nospam.softoak.demon.co.uk...
Viktor
Thomas Pomper <in...@koegel-leipzig.de> wrote in message
news:523401c07ae6$f0389280$46862ecf@cpmsftngxa06...
When one does certain things practically for free, the only reward is thanks
from the people who were helped.... if you strip the names you take that
away, too!
--
MichKa
a new book on internationalization in VB at
http://www.i18nWithVB.com/
"Tony Oakley" <To...@nospam.softoak.demon.co.uk> wrote in message
news:3A5C4113...@nospam.softoak.demon.co.uk...