Results 1 to 3 of 3

Thread: For Each TextBox...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    For Each TextBox...

    How can I cycle through all of the textbox controls on my form?

    I thought it was something like..

    VB Code:
    1. Dim txt as TextBox
    2. For Each txt in Me.Controls
    3.    'Do something :D
    4. Next


    But alas...
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    this is for VB6 or .net?

    either way your code is flawed in that you want to dim the var as a control
    VB Code:
    1. Dim ctrl as Control
    2. For Each ctrl in Me.Controls
    3.     if TypeOf ctrl Is Textbox then
    4.        'Do something
    5.     end if
    6. Next

    this is the VB6 method.. sorry im not sure if it applies to .net

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    VB Code:
    1. For Each ctrl as Control in Me.Controls
    2.     if TypeOf ctrl Is Textbox then
    3.        'Do something
    4.     end if
    5. Next
    \m/\m/

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