By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

AddressOf VB.net

P: n/a
Probably you might help me regarding this.. I'm new to these Vb.net
language. My question is Does AddressOf is accepted in Vb.net?

in this VbCode: I have this API
===================================
Public Declare Function SetCallbacks Lib "tfm.dll" ( _
ByVal hConn As Long, ByVal pfnGuiCallback As Long, ByVal
pGuiCallbackCtx As Long, ByVal pfnGuiStateCallback As Long, ByVal
pGuiStateCallbackCtx As Long) As Long

===Callback.bas - Module===
Result = SetCallbacks(Connection, 0&, 0&, AddressOf STATE_CALLBACK, 0&

- i have this module Callback.bas a procedure function called
STATE_CALLBACK

=======================================
Function STATE_CALLBACK(ByVal pGuiStateCallbackCtx As Long, ByVal
dwGuiState As Long, ByRef pbyRes As Byte, ByVal dwMsg As Long, ByVal
byProg As Byte, ByVal pSamBuf As Long, ByVal Data As Long) As Long
How will i convert this to vb.net???! I have a module for the
Callback..

what i did was with the same format
======================================
Result = SetCallbacks(Connection, 0, 0, AddressOf
Callback.STATE_CALLBACK, 0)

and the error appeared was "AddressOf expression cannot convertes to
integer because integer is not delegate type" Im getting stucked in
here... I need it badly..

I'll appreciate for helping me

tnx..
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The AddressOf operator is available in VB.NET also. However, the way you
implement callback procedures in VB.NET is a little different. First of all,
'Long' from VB6 converts to 'Integer' in VB.NET. Next, you can use delegates
to implement call procedures.
Here's how:

Delegate Function STATE_CALLBACK ( _
ByVal pGuiStateCallbackCtx As Integer, ByVal dwGuiState As Integer,
_
ByRef pbyRes As Byte, ByVal dwMsg As Integer, _
ByVal byProg As Byte, ByVal pSamBuf As Integer, _
ByVal Data As Integer) As Integer

Public Declare Function SetCallbacks Lib "tfm.dll" ( _
ByVal hConn As Integer, ByVal pfnGuiCallback As Integer, _
ByVal pGuiCallbackCtx As Integer, _
ByVal pfnGuiStateCallback As STATE_CALLBACK, _
ByVal pGuiStateCallbackCtx As Integer) As Integer
Function State_Cbk(ByVal pGuiStateCallbackCtx As Integer, _
ByVal dwGuiState As Integer, ByRef pbyRes As Byte, _
ByVal dwMsg As Integer, ByVal byProg As Byte, _
ByVal pSamBuf As Integer, ByVal Data As Integer) As Integer

' here goes your callback code..

End Function

In the SetCallbacks, I assume the remaining parameters also pass addresses
to callback procedures. But since you're using just one of them, you can
define the remaining as Integers and pass in 0. This is how you would call
the function.

Dim Result = SetCallbacks(Connection, 0, 0, AddressOf STATE_CALLBACK, 0)

hope that helps..
Imran.
"peter" <zo****@yahoo.com> wrote in message
news:1b**************************@posting.google.c om...
Probably you might help me regarding this.. I'm new to these Vb.net
language. My question is Does AddressOf is accepted in Vb.net?

in this VbCode: I have this API
===================================
Public Declare Function SetCallbacks Lib "tfm.dll" ( _
ByVal hConn As Long, ByVal pfnGuiCallback As Long, ByVal
pGuiCallbackCtx As Long, ByVal pfnGuiStateCallback As Long, ByVal
pGuiStateCallbackCtx As Long) As Long

===Callback.bas - Module===
Result = SetCallbacks(Connection, 0&, 0&, AddressOf STATE_CALLBACK, 0&

- i have this module Callback.bas a procedure function called
STATE_CALLBACK

=======================================
Function STATE_CALLBACK(ByVal pGuiStateCallbackCtx As Long, ByVal
dwGuiState As Long, ByRef pbyRes As Byte, ByVal dwMsg As Long, ByVal
byProg As Byte, ByVal pSamBuf As Long, ByVal Data As Long) As Long
How will i convert this to vb.net???! I have a module for the
Callback..

what i did was with the same format
======================================
Result = SetCallbacks(Connection, 0, 0, AddressOf
Callback.STATE_CALLBACK, 0)

and the error appeared was "AddressOf expression cannot convertes to
integer because integer is not delegate type" Im getting stucked in
here... I need it badly..

I'll appreciate for helping me

tnx..

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.