Results 1 to 3 of 3

Thread: text boxes

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Does any one know how i could erase all of the contents of my text boxes in my application?

    If text1.text = visible then
    erase text1.text '?????????????????

    I have no idea how to accomplish this task.

    Thanxxxxxx =C)

  2. #2
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    Here try this

    If text1.text = visible Then
    text1.text = ""
    End if
    Matt

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    To clear ALL the textboxes on your form...

    Declare a variable as a Control, and loop through all the controls on your form. If the type of control is a textbox, set it's caption to an empty string.

    Here's an example:

    Put a command button named Command1 on your form, and as many textboxes as you want. Then paste the following code into your form's code window.

    When you run the project, type text into all the textboxes. Then click the command button to clear them all.

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim Ctrl As Control
        
        For Each Ctrl In Me.Controls
            If TypeOf Ctrl Is TextBox Then
                Ctrl.Text = ""
            End If
        Next Ctrl
    End Sub
    ~seaweed

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