Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

  • Leaders
Posted

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.

  • Leaders
Posted

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

Posted
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.
.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...