I'm doing a task to find data in an array, in this example I have an array with values 01, 02, and 03.
What I do is put a value in a text box and in a FindKey function, indicate whether that value exists in the array. I do not know how I could be wrong since I only take the first value of the arrangement and therefore I always print the same message.
This is the code I have.
Dim VectorA() As String = {"01", "02", "03"}
Public Function buscarClaves(ByVal dts As String) As Boolean
'buscarClaves = False
For Each clave As String In VectorA
If clave = dts Then
Return True
Else
Return False
End If
Next
'
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 1 To VectorA.Length
If buscarClaves(TextBox1.Text) Then
MsgBox("Clave duplicado")
Else
MsgBox("Clave disponible")
End If
Next i
End Sub