B
Billy Jacobs
Can someone tell me what the problem with this code is.
Specifically the line in all caps near the bottom. I am
getting an error on this line saying:
"Property Access must assingn to the property or use its
value".
When I do that I get a different error saying:
"Expression does not produce a value"
I took this code and converted it from C# to VB.
Namespace MyDelegate
Public Delegate Sub PrintCallback(ByVal number As
Int32)
Public Class Printer
Private _print As PrintCallback
Public Property PrintCallback() As PrintCallback
Get
Return _print
End Get
Set(ByVal Value As PrintCallback)
_print = Value
End Set
End Property
Public Class Driver
Private Sub PrintInteger(ByVal number As
Integer)
Console.WriteLine("From PrintInteger: The
number is {0}.", number)
End Sub
Shared Sub main()
Dim driver As New Driver()
Dim printer As New Printer()
printer.PrintCallback = New PrintCallback
(AddressOf driver.PrintInteger)
printer.PrintCallback(10)
Console.WriteLine("Press enter to exit...")
Console.ReadLine()
End Sub
End Class
End Class
End Namespace
Specifically the line in all caps near the bottom. I am
getting an error on this line saying:
"Property Access must assingn to the property or use its
value".
When I do that I get a different error saying:
"Expression does not produce a value"
I took this code and converted it from C# to VB.
Namespace MyDelegate
Public Delegate Sub PrintCallback(ByVal number As
Int32)
Public Class Printer
Private _print As PrintCallback
Public Property PrintCallback() As PrintCallback
Get
Return _print
End Get
Set(ByVal Value As PrintCallback)
_print = Value
End Set
End Property
Public Class Driver
Private Sub PrintInteger(ByVal number As
Integer)
Console.WriteLine("From PrintInteger: The
number is {0}.", number)
End Sub
Shared Sub main()
Dim driver As New Driver()
Dim printer As New Printer()
printer.PrintCallback = New PrintCallback
(AddressOf driver.PrintInteger)
printer.PrintCallback(10)
Console.WriteLine("Press enter to exit...")
Console.ReadLine()
End Sub
End Class
End Class
End Namespace