DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   vb.net code for searching (http://www.daniweb.com/forums/thread123928.html)

pcr May 12th, 2008 10:12 pm
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.

Jx_Man May 12th, 2008 11:11 pm
Re: vb.net code for searching
 
show us your effort friend....

tratak May 13th, 2008 2:42 am
Re: vb.net code for searching
 
  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

pcr May 13th, 2008 6:52 pm
Re: vb.net code for searching
 
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

Jx_Man May 13th, 2008 9:13 pm
Re: vb.net code for searching
 
Quote:

Originally Posted by pcr (Post 606309)
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

pcr May 13th, 2008 10:28 pm
Re: vb.net code for searching
 
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

Jx_Man May 14th, 2008 12:20 am
Re: vb.net code for searching
 
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


All times are GMT -4. The time now is 7:38 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC