vb6清空所有文本框的7种方法
━━━━━━━━━━━━━━━━━━━━━━━━━
Option Explicit
Private Sub Command1_Click
()
Dim i
For i = 1 To 7
Me.Controls("Text" & i).Text = ""
Next
End Sub
Private Sub Command2_Click()
Dim a
For Each a In Me.Controls
If TypeOf a Is TextBox Then
a.Text = ""
End If
Next
End Sub
Private Sub Command3_Click()
Dim a
For Each a In Me.Controls
If TypeName(a) = "TextBox" Then
a.Text = ""
End If
Next
End Sub
Private Sub Command4_Click()
Dim a
For Each a In Me.Controls
If a.Tag = 1 Then
a.Text = ""
End If
Next
End Sub
Private Sub Command5_Click()
Dim a
For Each a In Me.Controls
If a.Left = Text1.Left Then
a.Text = ""
End If
Next
End Sub
Private Sub Command6_Click()
Dim i
For i = 0 To Me.Controls.Count - 1
If Me.Controls(i).Name Like "Text*" Then
Me.Controls(i).Text = ""
End If
Next
End Sub
Private Sub Command7_Click()
Dim a, i
For i = 0 To Me.Controls.Count - 1
If Me.Controls(i).TabIndex >= 7 And Me.Controls(i).TabIndex <= 13 Then
Me.Controls(i).Text = ""
End If
Next
End Sub
Private Sub Command8_Click()
Dim i
For i = 1 To 7
Me.Controls("Text" & i).Text = "Text" & i
Next
End Sub
加载中,请稍候......