If function

i have a code to search a datagrid to find the text i typed in the textbox.

when the wordt isn't found , or there is no text in the text box , i want a msgbox to open.

can somebody help me whit the code

Dim strcolumn, strsearchvalueAsString

strcolumn = CataloogDataSet2.boltype.Columns(0).ColumnName

strsearchvalue = toolstriptextbox1.Text

Me.BoltypeBindingSource.Position =Me.BoltypeBindingSource.Find(strcolumn, strsearchvalue)

[936 byte] By [mustangBE] at [2007-12-30]
# 1
Try this...

Dim strcolumn, strsearchvalue As String

strcolumn = CataloogDataSet2.boltype.Columns(0).ColumnName

strsearchvalue = toolstriptextbox1.Text

Dim index As int

index = Me.BoltypeBindingSource.Find(strcolumn, strsearchvalue)

If index >= 0 Then

Me.BoltypeBindingSource.Position = index

Else

MessageBox.Show("Not Found!")

End If

just check for any syntax errors as i'm typing this code directly without testing it in VS IDE.

LeonTayson at 2007-9-5 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Works great THANKS

but if i press the button when the textbox is empty i get following error

System.FormatException was unhandled

mustangBE at 2007-9-5 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

oh, i didn't notice that condition... here goes...

Dim index As int = -1

if strsearchvalue.Length > 0 Then

index = Me.BoltypeBindingSource.Find(strcolumn, strsearchvalue)

End If

If index >= 0 Then

Me.BoltypeBindingSource.Position = index

Else

MessageBox.Show("Not Found!")

End If

LeonTayson at 2007-9-5 > top of Msdn Tech,Visual Basic,Visual Basic General...