Results 1 to 2 of 2

Thread: control arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    Question control arrays

    In vb6 we could easily create an array of controls at runtime.
    I need to create an array of controls at runtime in vb.net, so hoe can i do that?

  2. #2
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256
    contorl arrays no longer exists in vb.net, but you can control events using add handler, like so....

    but the following the the form load event

    VB Code:
    1. AddHandler textbox1.keypress, addressof textbox_keypress
    2. AddHandler textbox2.keypress, addressof textbox_keypress

    then have a sub call

    VB Code:
    1. Private Sub textbox_keypress(ByVal sender as object, ByVal e as System.Windows.Forms.KeyPressEventArgs)
    2. If (e.KeyChar < "0" or e.KeyChar > "9") and e.KeyChar <> ChrW(8) Then
    3.      e.handled = true
    4. End If
    5. End Sub

    Jeff
    Last edited by jkw119; Jun 23rd, 2002 at 10:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width