Reputation: 17
Private Sub txtQty_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.GotFocus
Dim strItem As String
strItem = txtItem.Text
Dim strArray As String
strArray = itemArr(1)
If String.Compare(strItem, strArray) = True Then
MessageBox.Show("item in array!")
End If
End Sub
Private Sub txtQty_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.TextChanged
If txtItem.Text <> Nothing And txtQty.Text <> Nothing Then
'create rows in the DataTable
tblScItem.Rows.Add(itemArray())
End If
txtItem.Text = ""
txtQty.Text = ""
End Sub
This is how i declare my array:
Function itemArray() As String()
itemArr(0) = ""
itemArr(1) = txtItem.Text
itemArr(2) = Form2.cbGondola.SelectedItem
itemArr(3) = txtQty.Text
itemArr(4) = DateTime.Now
itemArr(5) = Form1.txtLoginId.Text
Return itemArr
End Function
I dont seem to do a proper check, help!
Upvotes: 1
Views: 2739
Reputation: 700192
The String.Compare
method doesn't return a boolean, it returns an integer.
If the strings are equal, it returns 0
.
If String.Compare(strItem, strArray) = 0 Then
You should set Option Strict
to On
in your project, so that the compiler won't allow the implicit conversion from boolean to integer.
Upvotes: 1