hobbes2103 Posted July 22, 2003 Posted July 22, 2003 I have this problem with the Addhandler syntax : Tutorials all give this syntax AddHandler obj.event, AdressOf obj_event But I have the following code : Dim x As New TextBox() x.Name = "TextBox3" x.Location = New Point(112, 416) Me.Controls.Add(x) AddHandler x.MouseEnter, AddressOf textbox3_MouseEnter And 'TextBox3_MouseEnter' is underlined and i'm asked to declare it (and the prog won't work) Do i really have to declare it and if yes, how should i declare it? Please help me!! :eek: Quote
Leaders dynamic_sysop Posted July 22, 2003 Leaders Posted July 22, 2003 withevents at the area just below " windows generated code " Dim WithEvents x As TextBox '///// '//// in a click or sub..... x.Name = "TextBox3" x.Location = New Point(112, 416) x = New TextBox() Me.Controls.Add(x) AddHandler x.MouseEnter, AddressOf textbox3_MouseEnter sommet like that. Quote
Leaders dynamic_sysop Posted July 22, 2003 Leaders Posted July 22, 2003 here's a working example : Dim WithEvents x As Button '//////////////////////////////// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click x = New Button() x.Text = "button3" x.Location = New System.Drawing.Point(300, 50) x.Visible = True Me.Controls.Add(x) AddHandler x.Click, AddressOf Button1_Click End Sub Quote
Heiko Posted July 22, 2003 Posted July 22, 2003 Sorry if you think this is obvious, but other than in old VB6 you need to have the program code, i.e. the function that will later work as the event handler *beforehand* (well not the entire code, but the signature). It will not be auto-generated. Quote .nerd
hobbes2103 Posted July 22, 2003 Author Posted July 22, 2003 Thank you! (and don't worry it is not obvious at all to me) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.