Textbox loop

A

Al

Hi All,

Anyone know how to make the following loop not include textbox10 and
textbox11?

Cheers

-Al

Private Sub ClearBoxes()

Dim myControl As Control

For Each myControl In Frame1.Controls

If TypeOf myControl Is TextBox Then

myControl.Text = ""

End If

Next

End Sub
 
D

David Cooper

You should be able to reference the "name" property of the control just as
you have referenced the text property. So for your code below add:

if myControl.Name <> "textbox10" or myControl.Name <> "textbox11" then
myControl.text=""
end if
 
D

Dave Lett

There are several ways to handle this, so this is just one:

For Each mycontrol In Frame1.Controls
If TypeOf mycontrol Is TextBox Then
Select Case mycontrol.Name
Case "TextBox10", "TextBox11" ' this is case senstive
' do nothing
Case Else
mycontrol.Text = ""
End Select
End If
Next


HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top