Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

Clear All Routine
(1 viewing) (1) Guest
VB.NET HELP, VB.NET TUTORIALS, VB.NET CODE, VB.NET PROGRAMMING, VB.NET

Visual Basic.NET is the most recent generation of Visual Basic. Developers will be pleased to note that its new features include inheritance, method overloading, structured exception handling, and more. These capabilities make it easier than ever to create .NET applications, including Windows applications, web services, and web applications. The articles in this section give you all the tips you need to work wit this useful language.
  • Page:
  • 1

TOPIC: Clear All Routine

Clear All Routine 09 Dec 2009 15:32 #72

clear eventhing on a form and can be used when using sub proecdure

 
Public Class frmClearAll
 
'Clear all controls on Form
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles btnClear.Click
ClearAll(Me) '
Call Sub procedure to clear Form
End Sub
 
'Sub procedure to clear all Text Boxes, Masked Text Boxes, and Check Boxes on Form
Private Sub ClearAll(ByVal C As Control)
 
Dim Ctrl As Control '
Declare generic control object
Dim MyCheckBox As CheckBox 'Declare CheckBox control object
 
For Each Ctrl In C.Controls
Select Case TypeName(Ctrl)
Case "TextBox" '
Do the following code if control is a Text Box
Ctrl.Text = ""
Case "MaskedTextBox" 'Do the following code if control is a Masked Text Box
Ctrl.Text = ""
Case "CheckBox" '
Do the following code if control is a Check Box
MyCheckBox = CType(Ctrl, CheckBox) 'Use here as generic control type
MyCheckBox.Checked = False '
Ctrl doesn’t have Checked property
Case Else
If Ctrl.Controls.Count > 0 Then 'Check for container control
ClearAll(Ctrl) '
Recursively call sub for controls in container
End If
End Select
Next Ctrl
End Sub
 
End Class
 
 
  • CE
  • OFFLINE
  • Administrator
  • Posts: 197
  • Karma: 78
CodersEngine
  • Page:
  • 1
Time to create page: 0.32 seconds