Luc
Well-known member
- Joined
- Nov 29, 2005
- Messages
- 59
- Programming Experience
- 1-3
Can someone tell me what i'm doing wrong? I made a new project to practice delegates and i keep getting a nullrefrence error on my
here is the full code, it doesnt do annything usefull, i was just running some tests.
[FONT="][/FONT]
VB.NET:
DLGtekst.Invoke(value)
here is the full code, it doesnt do annything usefull, i was just running some tests.
VB.NET:
Public Class Form1
Dim t As New test
Dim x As Integer = 0
Private Sub test_invokes()
t.tekstchange(New test.tekst(AddressOf TextBox1_tekst))
End Sub
Private Sub Textbox1_tekst(ByVal aantal As Integer)
TextBox1.Text = "the text has been delegated" & CStr(aantal) & "times"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
x += 1
t.aantal = x
End Sub
End Class
Public Class test
Public Delegate Sub tekst(ByVal aantal As Integer)
Public DLGtekst As tekst
Dim prop_aantal%
Public Sub tekstchange(ByVal value As tekst)
DLGtekst = value
End Sub
Public Property aantal() As Integer
Get
Return prop_aantal
End Get
Set(ByVal value As Integer)
DLGtekst.Invoke(value)
End Set
End Property
End Class