Results 1 to 11 of 11

Thread: Clear form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    The Void
    Posts
    23

    Question Clear form

    I'm new to Visual Basic, and I'm really interested in learning the language. I've been playing around with it, but can't get it to do anything I have a form, with a command button on it, I assign the button to print text (using print "insert text here"), I want to create another button, which when clicked, will clear all the text. Could anyone tell me how to do this? Any help would be appreciated. (Plus any sites which could help me learn VB would be nice as well Thanks again.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Sub Command1_Click()
    2. Text1.Text = ""
    3. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    The Void
    Posts
    23

    Run Time error :-/

    I put in the code just as you wrote it, when I pressed that button, I would get the following error:

    Run-Time error '424':

    Object Required.


  4. #4
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    you have to put a textbox on your form

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    The Void
    Posts
    23

    Why?

    I'm not printing text on a text box, I'm printing it to the form, is there no way to clear the text from the form, will it only work in a text box?

  6. #6
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    its impossible to put just plain text on a form you have to have some control

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Form1.Cls

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    The Void
    Posts
    23
    It's not impossible, I'm doing it. I have a form, and a command button, I have my command button set to the following:

    Private Sub cmdClick_Click()
    Print "Testing"
    End Sub

    When I run the program, I click the button and it prints the text on the form.

  9. #9
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    o ok sry...you know you could use a msgbox 2

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Cls will clear the form of all text printed on it.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    The Void
    Posts
    23

    Hack solved it :)

    Hack Solved my problem. Thanks

    I didn't know you could use .cls :-/

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