2010-10-28 38 views
0

我只編譯了下面的小應用程序我希望在用戶切換選項卡時清除所有textpoxes,如何實現這一點?幫我清除所有文本框?

Public Class Form1 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Dim FILE_NAME As String = "C:\test.pgp" 

    If System.IO.File.Exists(FILE_NAME) = True Then 
     Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True) 
     objWriter.WriteLine((TextBox2.Text) + "," + "  " + "*" + (TextBox1.Text)) 
     objWriter.Close() 
     MsgBox("The acad.pgp file was successfully appended…") 
    Else 
     MsgBox("File missing reinstall or contact vendor…") 
    End If 
End Sub 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 
    Dim FILE_NAME As String = "C:\test.pgp" 

    If System.IO.File.Exists(FILE_NAME) = True Then 
     Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True) 
     objWriter.WriteLine((TextBox3.Text) + "," + "  " + "START " + (TextBox4.Text) + ", 1,,") 
     objWriter.Close() 
     MsgBox("The acad.pgp file was successfully appended…") 
    Else 
     MsgBox("File missing reinstall or contact vendor…") 
    End If 
End Sub 

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click 
    Dim FILE_NAME As String = "C:\test.pgp" 

    If System.IO.File.Exists(FILE_NAME) = True Then 
     Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True) 
     objWriter.WriteLine((TextBox5.Text) + "," + "  " + "START " + (TextBox6.Text) + ", 1,,") 
     objWriter.Close() 
     MsgBox("The acad.pgp file was successfully appended…") 
    Else 
     MsgBox("File missing reinstall or contact vendor…") 
    End If 

末級

+1

這是*不* VBA。請正確標記問題。 – Fionnuala 2010-10-28 19:44:45

回答

1
Public Sub ClearTextBoxes(frmClearMe As Form) 

Dim txt As Control 

    For Each txt In frmClearMe 

    If TypeOf txt Is TextBox Then txt.Text = "" 

    Next 

End Sub 
+0

Call me dumb but this with following section of code?Private Sub TabPage1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles TabPage1.Click End Sub – 2010-10-28 13:48:43