K
kberry
I am clearing Textboxes on a form... this is loop I have came up with
but was wondering if it can be shorter or not as long... Can anyone
help?
Dim controlOnForm As Control 'Places a control on the form
Dim controlOnTab As Control 'Places a control on the tab
Dim controlTabPage As Control 'Places a control on the tab
page
Dim controlGroupBox As Control 'Places a control on the group
box
For Each controlOnForm In Me.Controls 'Focus on the form
For Each controlOnTab In controlOnForm.Controls 'Focus on
the Tab
For Each controlTabPage In controlOnTab.Controls 'Focus
on the Tab Page
If TypeOf controlTabPage Is TextBox Then 'Focus on
the Textboxes
controlTabPage.Text = "" 'Clear Textbox
End If
If TypeOf controlTabPage Is ComboBox Then 'Focus on
the ComboBox
controlTabPage.Text = "" 'Clear ComboBox
End If
For Each controlGroupBox In controlTabPage.Controls
'Focus on the GroupBox
If TypeOf controlGroupBox Is TextBox Then
'Focus on the Textbox
controlGroupBox.Text = "" 'Clear Textbox
End If
Next
Next
Next
Next
Thought it would be easier in .NET than in VB6...
but was wondering if it can be shorter or not as long... Can anyone
help?
Dim controlOnForm As Control 'Places a control on the form
Dim controlOnTab As Control 'Places a control on the tab
Dim controlTabPage As Control 'Places a control on the tab
page
Dim controlGroupBox As Control 'Places a control on the group
box
For Each controlOnForm In Me.Controls 'Focus on the form
For Each controlOnTab In controlOnForm.Controls 'Focus on
the Tab
For Each controlTabPage In controlOnTab.Controls 'Focus
on the Tab Page
If TypeOf controlTabPage Is TextBox Then 'Focus on
the Textboxes
controlTabPage.Text = "" 'Clear Textbox
End If
If TypeOf controlTabPage Is ComboBox Then 'Focus on
the ComboBox
controlTabPage.Text = "" 'Clear ComboBox
End If
For Each controlGroupBox In controlTabPage.Controls
'Focus on the GroupBox
If TypeOf controlGroupBox Is TextBox Then
'Focus on the Textbox
controlGroupBox.Text = "" 'Clear Textbox
End If
Next
Next
Next
Next
Thought it would be easier in .NET than in VB6...