Author Topic: Activate new window  (Read 20280 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Activate new window
« Reply #15 on: November 27, 2003, 09:38:11 AM »
AddressOf is not valid in VBA, there is a workaround on the vbdesign.net website
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Activate new window
« Reply #16 on: November 27, 2003, 09:46:16 AM »
Thought as much. It seemed a bit indigestible in VBA.
Oh, I better quit this thread now before I actually manage to learn VBA  :shock:

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Activate new window
« Reply #17 on: November 27, 2003, 10:29:30 AM »
Try this in VBA to return the AddressOf ...

Public Function MyAddressOf(sFuncName As String) As Long
' This function Returns a function pointer of a VBA public function.
' Since the VB AddressOf operator which is not supported in VBA, call this
' function passing in the name of the function you want the pointer to.        
' Generic return result so we can test our function calls for errors    

 Dim lResult As Long
' To hold the handle to the current project    
 Dim lHproject As Long
' To hold the ID of our function name as it is known by the system
Dim sFuncID As String
' To hold the final result (the return value of MyAddressOf)    
' It is the same as if we had used the standard VB AddressOf function    
' but remember, that is not supported in VBA

Dim lFuncPtr As Long
' The function name you passed in when you called MyAddressOf needs    
' to be converted to Unicode in order for it to be found by GetFuncID    
' This will hold that conversion

Dim sFuncNameUnicode As String
' Convert the passed in function name (the one we want the address of) to Unicode
sFuncNameUnicode = StrConv(sFuncName, vbUnicode)            
' Get the current VBA project handle
Call GetCurrentVbaProject(lHproject)            
' Make sure we got a project handle
If lHproject <> 0 Then
' Get the VBA function ID (this is the ID of the function we passed in to MyAddressOf)
lResult = GetFuncID(lHproject, sFuncNameUnicode, sFuncID)                
' Again, check for an error so we don't try to get a pointer to    
' a non-existent function.

If lResult = NO_ERROR Then
' Get the function pointer.
lResult = GetAddr (lHproject, sFuncID, lFuncPtr)                      
If lResult = NO_ERROR Then
' Return the pointer to the function we passed in
MyAddressOf = lFuncPtr      
End If    
End If    
End If      
End Function

You will need to replace the AddressOf call in the code with MyAddressOf to make it work....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Activate new window
« Reply #18 on: November 27, 2003, 10:49:02 AM »
Cool. That's a keeper for future reference. Thanks.

Off to Vegas for now. See you guys in week or so!

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Activate new window
« Reply #19 on: November 27, 2003, 12:38:36 PM »
>Off to Vegas for now. See you guys in week or so!
Enjoy, I know I would. :D
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
Activate new window
« Reply #20 on: November 27, 2003, 12:45:03 PM »
Thanks Mark.
15 hours till the flight, though, so just got time to browse a bit

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Activate new window
« Reply #21 on: November 27, 2003, 12:55:03 PM »
Bring back lots of info for us to read. <g>
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Activate new window
« Reply #22 on: November 27, 2003, 12:56:20 PM »
Vegas!!! Welcome to the USA!!!!

(leave your cash at the craps table)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Activate new window
« Reply #23 on: November 27, 2003, 12:59:15 PM »
Quote from: Mark Thomas
Bring back lots of info for us to read. <g>

Huh? Is it the purpose of AU to study something? C'mon, it's Las Vegas .. I expect to return with a trunk full of cash!

SMadsen

  • Guest
Activate new window
« Reply #24 on: November 27, 2003, 01:02:06 PM »
Or is it just to return in a trunk? :?

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Activate new window
« Reply #25 on: November 27, 2003, 01:04:45 PM »
> I expect to return with a trunk full of cash!

good luck them. :D
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
Activate new window
« Reply #26 on: November 29, 2003, 01:13:31 AM »
Hah! I'll see you there. I'll probably be the only one trying to apply what I learn. I don't really care much for Vegas. Been there twice and was less impressed the second time than I was the first time.