473,396 Members | 2,037 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,396 software developers and data experts.

stuck with callback / delegate

I tried to implement a callback as described in the MSDN Mag article 2003/1 p105ff 'Implementing Callbacks'.
I have no idea, of what could be different in my code, but for some reason, I get an error in form of a code outline:
Delegate Function FormatDBRows(ByVal objA As ArrayList) As String

'-----------------------------------------------------------
Public Class DBRow

Private obj As Object
Private objFields As System.Collections.ArrayList
Private objHandler As FormatDBRows

Public Sub New(ByVal iNrOfFields As Integer)
objFields = New ArrayList(iNrOfFields)
End Sub

Public Property Item(ByVal iItemNr As Integer) As Object
Get
Return objFields.Item(iItemNr)
End Get
Set(ByVal Value As Object)
objFields.Item(iItemNr) = Value
End Set
End Property

''objH' cannot expose a Friend type outside of the Public class 'DBRow'.
Public Sub RegisterHandler(ByVal objH As FormatDBRows)
Me.objHandler = objH
End Sub

Overrides Function ToString() As String
Dim strFormatedString As String
strFormatedString = Me.objHandler.Invoke(objFields)

Return "strFormatedString"
End Function
End Class
'-----------------------------------------------------------

The portion "FormatDBRows" of the Sub RegisterHandler is being underlined with the tooltip:
'objH' cannot expose a Friend type outside of the Public class 'DBRow'.

Any ideas?
Thank you,
Wolfgang

Nov 20 '05 #1
3 2242
In article <uZ*************@TK2MSFTNGP10.phx.gbl>, Wolfgang Kaml wrote:

<snip>
Delegate Function FormatDBRows(ByVal objA As ArrayList) As String


Make the delegate declaration Public....
Public Delegate Function FormatDBRows(ByVal objA As ArrayList) As String

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
Wolfgang,
The default visible for most constructs in VB.NET is Friend, friends cannot
be exposed by Public. You need to make your Delegate Public

Public Delegate Function FormatDBRows(ByVal objA As ArrayList) As String

Hope this helps
Jay

"Wolfgang Kaml" <ms@no-spam.kaml.com> wrote in message
news:uZ*************@TK2MSFTNGP10.phx.gbl...
I tried to implement a callback as described in the MSDN Mag article 2003/1
p105ff 'Implementing Callbacks'.
I have no idea, of what could be different in my code, but for some reason,
I get an error in form of a code outline:
Delegate Function FormatDBRows(ByVal objA As ArrayList) As String

'-----------------------------------------------------------
Public Class DBRow

Private obj As Object
Private objFields As System.Collections.ArrayList
Private objHandler As FormatDBRows

Public Sub New(ByVal iNrOfFields As Integer)
objFields = New ArrayList(iNrOfFields)
End Sub

Public Property Item(ByVal iItemNr As Integer) As Object
Get
Return objFields.Item(iItemNr)
End Get
Set(ByVal Value As Object)
objFields.Item(iItemNr) = Value
End Set
End Property

''objH' cannot expose a Friend type outside of the Public class 'DBRow'.
Public Sub RegisterHandler(ByVal objH As FormatDBRows)
Me.objHandler = objH
End Sub

Overrides Function ToString() As String
Dim strFormatedString As String
strFormatedString = Me.objHandler.Invoke(objFields)

Return "strFormatedString"
End Function
End Class
'-----------------------------------------------------------

The portion "FormatDBRows" of the Sub RegisterHandler is being underlined
with the tooltip:
'objH' cannot expose a Friend type outside of the Public class 'DBRow'.

Any ideas?
Thank you,
Wolfgang
Nov 20 '05 #3
Thanks so much to all of you folks! - I hope that the idea will work out
that I am trying to accomplish with this class: To make a DB reporting class
that will take any SQL statement for selection, and will create an output
based on an outside function that is being linked through a callback.

Wolfgang
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
Wolfgang,
The default visible for most constructs in VB.NET is Friend, friends cannot be exposed by Public. You need to make your Delegate Public

Public Delegate Function FormatDBRows(ByVal objA As ArrayList) As String
Hope this helps
Jay

"Wolfgang Kaml" <ms@no-spam.kaml.com> wrote in message
news:uZ*************@TK2MSFTNGP10.phx.gbl...
I tried to implement a callback as described in the MSDN Mag article 2003/1 p105ff 'Implementing Callbacks'.
I have no idea, of what could be different in my code, but for some reason, I get an error in form of a code outline:
Delegate Function FormatDBRows(ByVal objA As ArrayList) As String

'-----------------------------------------------------------
Public Class DBRow

Private obj As Object
Private objFields As System.Collections.ArrayList
Private objHandler As FormatDBRows

Public Sub New(ByVal iNrOfFields As Integer)
objFields = New ArrayList(iNrOfFields)
End Sub

Public Property Item(ByVal iItemNr As Integer) As Object
Get
Return objFields.Item(iItemNr)
End Get
Set(ByVal Value As Object)
objFields.Item(iItemNr) = Value
End Set
End Property

''objH' cannot expose a Friend type outside of the Public class 'DBRow'. Public Sub RegisterHandler(ByVal objH As FormatDBRows)
Me.objHandler = objH
End Sub

Overrides Function ToString() As String
Dim strFormatedString As String
strFormatedString = Me.objHandler.Invoke(objFields)

Return "strFormatedString"
End Function
End Class
'-----------------------------------------------------------

The portion "FormatDBRows" of the Sub RegisterHandler is being underlined
with the tooltip:
'objH' cannot expose a Friend type outside of the Public class 'DBRow'.

Any ideas?
Thank you,
Wolfgang

Nov 20 '05 #4

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

Similar topics

10
by: John Bowman | last post by:
Hello, I need some help getting a callback delegate passed as an argument to a dynamically linked Dll method so it in turn, can eventually call it. Below is the salient portions of code I'm...
4
by: Sai Kit Tong | last post by:
I have to interface managed application with my legacy dll. I have employed the wrapper approach but I have to deal with the asynchronous callback from the legacy dll, which likely goes through a...
2
by: Gerda | last post by:
Hi! I've implemented many times an asynchronous call of a method with a call backfunction successfully. But to implement this with VB.NET is not so successfully. I can implement all events...
4
by: FishingScout | last post by:
I am re-writing an MS VC++ 6.0 application in Visual Studio 2005 VB.NET. In order for my new application to communicate with some hardware (an RFID reader) I need to communicate with a DLL that...
3
by: sklett | last post by:
Just when I thought working with this unmanaged DLL could get any more difficult.... I have to deal with this: <exception> {"An attempt was made to load a program with an incorrect format....
6
by: Bart Burkhardt | last post by:
Hi, I could use some help in setting a C# callback function that an external unmanaged dll will call on a event. Using a delegate and use the external callback set function doesn't work. The...
13
by: Wilfried Mestdagh | last post by:
Hi, I have an application using a DLL and callbacks. It generate random the error "A callback was made on a garbage collected delegate". I found some articles that the pointer to the delegate...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
5
by: Jef Driesen | last post by:
I have a C DLL that I want to use from a C# project. The C header file contains these declarations: typedef void (*callback_t) (const unsigned char *data, unsigned int size, void *userdata);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.