1
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

これが私の配列を宣言する方法です:

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

私は適切なチェックをしていないようです、助けてください!

4

1 に答える 1

1

このString.Compareメソッドはブール値を返さず、整数を返します。

文字列が等しい場合、 を返します0

If String.Compare(strItem, strArray) = 0 Then

コンパイラがブール値から整数への暗黙的な変換を許可しないように、プロジェクトでを設定する必要がOption Strictあります。On

于 2012-09-26T10:22:24.320 に答える