How to check if a string is in array

sktanmoy

Active Member
Licensed User
Longtime User
Let we've an array of date

B4X:
Dim Days() As String
Days = Array As String("Sunday", "Monday", "Friday")

Now I was given a value Friday. How can I check if the given value is in the array?
 

JonPM

Well-Known Member
Licensed User
Longtime User
B4X:
Dim Days() As String
Days = Array As String("Sunday", "Monday", "Friday")

For i = 0 To Days.Length-1
   If Days(i) = "Friday" Then
      Msgbox("Friday is in the Array!", "")
   End If
Next
 
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
Insert an Exit after the value is found:

B4X:
Dim Days() As String
Days = Array As String("Sunday", "Monday", "Friday")

For i = 0 To Days.Length-1
   If Days(i) = "Friday" Then
      Msgbox("Friday is in the Array!", "")
      Exit
   End If
Next
 
Upvote 0
Top