954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

vb.net code for searching

Can anyone please send code for search form which contains clearing controls,validating and contains same criteria when you click search again button.

pcr
Newbie Poster
6 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

show us your effort friend....

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 
Dim txtb() As TextBox = {txtA, txtB, txtC}
           For Each ctrl As TextBox In txtb
                ctrl.Text = "" 
           Next


or

For Each ctrl As Object In Me.Controls
                If ctrl.GetType.Name = "TextBox" Then
                    ' do something
                End If
          Next
tratak
Newbie Poster
3 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

can you please send sample program with some search criteria,including clearing controls,validating and search criteria remains same when you click revise again in search form

pcr
Newbie Poster
6 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 
can you please send sample program with some search criteria,including clearing controls,validating and search criteria remains same when you click revise again in search form


Tratak was given u a codes, use it. however you didn't show how far u done with this? where is your effort? have u read a rules?? We only give homework help to those who show effort

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

sub clear()

me.combobox1.clear()
me.combobox2.clear()
me.textbox1.clear()
end sub

Private Sub nameTextBox1_Validated(sender As Object, e As System.EventArgs) Handles nameTextBox1.Validated
If IsNameValid() Then
' Clear the error, if any, in the error provider.
nameErrorProvider.SetError(Me.nameTextBox1, "")
Else
' Set the error if the name is not valid.
nameErrorProvider.SetError(Me.nameTextBox1, "Name is required.")
End If
End Sub

pcr
Newbie Poster
6 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

this following code to clear controls, you can add what control you want to clear :

Public Sub ClearControl(ByVal root As Control)
        For Each ctrl As Control In root.Controls
            ClearControl(ctrl)
            If TypeOf ctrl Is TextBox Then
                CType(ctrl, TextBox).Text = String.Empty
            ElseIf TypeOf ctrl Is ComboBox Then
                CType(ctrl, ComboBox).Text = String.Empty
            End If
        Next ctrl
    End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    ClearControl(Me)
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You