473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

'AddressOf' expression cannot be converted to 'Integer' because 'Integer'is not a delegate type.

I am *trying* to convert a VB6 program to vb.net. One error I am getting
that I cannot figure out is:

'AddressOf' expression cannot be converted to 'Integer' because
'Integer' is not a delegate type.

This is the offending line where the error is located:

res = UUIRTSetReceiveCallback(hDrvHandle, AddressOf IRReceiveCallback, Me)

This is the sub routine it is calling from the "AddressOf"

Public Sub IRReceiveCallback(ByVal IRCode As Integer, ByVal userData As
Integer)
Call PostMessage(frmMain.NewPtr, WM_GOT_RECEIVE, 0, IRCode)
End Sub
How can I modify this to use a "delegate"?
Nov 21 '05 #1
3 7457
Look through this article, please:
http://msdn.microsoft.com/library/de...raddressof.asp

"Patrick Dugan" <pa******@netins.net> wrote in message
news:ek****************@TK2MSFTNGP12.phx.gbl...
I am *trying* to convert a VB6 program to vb.net. One error I am getting
that I cannot figure out is:

'AddressOf' expression cannot be converted to 'Integer' because 'Integer'
is not a delegate type.

This is the offending line where the error is located:

res = UUIRTSetReceiveCallback(hDrvHandle, AddressOf IRReceiveCallback, Me)

This is the sub routine it is calling from the "AddressOf"

Public Sub IRReceiveCallback(ByVal IRCode As Integer, ByVal userData As
Integer)
Call PostMessage(frmMain.NewPtr, WM_GOT_RECEIVE, 0, IRCode)
End Sub
How can I modify this to use a "delegate"?

Nov 21 '05 #2
The AddressOf will only take a name without parameters.. Example:

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething) ' ok

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething(i As Integer)) '
error

All you need to do is create your delegate:

Delegate sub SomeName (IRCode As Integer, userData As Integer)

Then you can create your sub. Example

Private Sub SomeSub (iNumber As Integer, iNumber2 As SomeName) 'Use Delegate
....
End Sub
Nov 21 '05 #3
Thanks! The example that was mentioned previously wasn't much help. I
appreciate the assistance!

"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
The AddressOf will only take a name without parameters.. Example:

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething) ' ok

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething(i As Integer))
'
error

All you need to do is create your delegate:

Delegate sub SomeName (IRCode As Integer, userData As Integer)

Then you can create your sub. Example

Private Sub SomeSub (iNumber As Integer, iNumber2 As SomeName) 'Use
Delegate
...
End Sub

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: | last post by:
I am trying to run the following agregate function in a parameterized query on Access2000: Min(.*sqr(./.)/) The query saved OK, but an attempt to run it results in the message: The expression...
3
by: William Mild | last post by:
I am porting old Dreamweaver generated ASP code to ASP.NET (VBScript to VB.NET). Error: Cast from type 'Field' to type 'Integer' is not valid The error occurs on the line which says "rsStudents =...
4
by: Portroe | last post by:
on running debug I get the following error, ' cast from string "" to type 'integer' is not valid,' I am experimenting with file writing and reading, what sort of error am I looking for in my...
0
by: Carl Gilbert | last post by:
Hi I am trying to use a custom attribute that takes in an array or list of custom objects. Ths custom object has a text property and a type property. I have a custom attribute which has a...
8
by: gk245 | last post by:
This is part of a bigger program, but i made it simple (basically the OT_hours function is supposed to determine if the number entered is over 40 hours or not and return the appropriate answer): ...
35
by: Frederick Gotham | last post by:
I'm writing a template, and I need to know the maximum value of a given integer type at compile time. something like: template<class NumType> class Arb { public: static NumType const max =...
1
by: ashiremath | last post by:
Hi All Below the code giving me the error is Constant expression is required. Please help me for this program. Private Sub Send_InputChoice() Dim Input_String As Integer ...
3
by: Rob Blackmore | last post by:
I am trying to create an attribute of type Icon and have the following code: <AttributeUsage(AttributeTargets.Class)_ Public Class PIMSGridViewIconAttribute Inherits System.Attribute '///...
8
by: PJ6 | last post by:
Const factor As Double = Math.Sqrt(3) / 6 Error 1 Constant expression is required. This looks like laziness to me. In SQL Server, functions are given a distinction between ones that always...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.