Results 1 to 4 of 4

Thread: Dynamically blank all text controls on a form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    31

    Dynamically blank all text controls on a form

    Hi,

    I'd like to know is it possible to do something like the following

    VB Code:
    1. For each objcontrol in form.controls
    2.   if objcontrol is a textbox
    3.     objcontrol.text = ""
    4.   end if
    5. Next

    Is this possible

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamically blank all text controls on a form

    Moved from CodeBank.

    This is how you would code it:
    VB Code:
    1. Dim ctrl As Control
    2. For ctrl In Me.Controls
    3.   If TypeOf ctrl Is TextBox Then
    4.     ctrl.text =  vbNullString
    5.   End If
    6. Next

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    31

    Re: Dynamically blank all text controls on a form

    Thanks Hack,

    I just realised I had posted it in the wrong place. Was browsing through the codebank and hit new thread from there Typeof was the keyword I was looking for

    Cheers

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamically blank all text controls on a form

    Quote Originally Posted by simonhorne
    I just realised I had posted it in the wrong place. Was browsing through the codebank and hit new thread from there
    Happens all the time.

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