Here i have my simple code, containt list of arrays and 2 text boxes, when i press button script must check if text form Textbox2 is found in list of array. Can you help me to fix it ? Thanks !
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim pins() As String = {"dgge", "wada", "caas", "reaa"}
If TextBox2.Text = pins() Then
TextBox1.Text = "Succes"
End If End Sub
If you want to use LINQ, you can just do this:
If pins.Contains(TextBox2.Text) Then
TextBox1.Text = "Success"
End If
Otherwise, the easiest option would be to use a List instead of an array:
Dim pins As New List(Of String)(New String() {"dgge", "wada", "caas", "reaa"})
If pins.Contains(TextBox2.Text) Then
TextBox1.Text = "Success"
End If
But, if you must use an array, you can use the IndexOf method in the Array class:
If Array.IndexOf(TextBox2.Text) >=0 Then
TextBox1.Text = "Success"
End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With