sktanmoy Active Member Licensed User Longtime User Feb 1, 2013 #1 Let we've an array of date Code: Copy 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?
Let we've an array of date Code: Copy 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 Feb 1, 2013 #2 Code: Copy 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
Code: Copy 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
R Roger Garstang Well-Known Member Licensed User Longtime User Feb 1, 2013 #3 I usually break/exit the For if found too that way it doesn't scan the rest of the array/list after found. Upvote 0
I usually break/exit the For if found too that way it doesn't scan the rest of the array/list after found.
sktanmoy Active Member Licensed User Longtime User Feb 1, 2013 #4 Example Roger Garstang said: I usually break/exit the For if found too that way it doesn't scan the rest of the array/list after found. Click to expand... An example please Upvote 0
Example Roger Garstang said: I usually break/exit the For if found too that way it doesn't scan the rest of the array/list after found. Click to expand... An example please
P pixelpop Active Member Licensed User Longtime User Feb 1, 2013 #5 Insert an Exit after the value is found: JonPM said: Code: Copy 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 Click to expand... Upvote 0
Insert an Exit after the value is found: JonPM said: Code: Copy 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 Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Feb 3, 2013 #6 Another option: Code: Copy Dim list1 As List list1.Initialize2(Days) Dim i As Int = list1.IndexOf("Friday") Upvote 0
Another option: Code: Copy Dim list1 As List list1.Initialize2(Days) Dim i As Int = list1.IndexOf("Friday")
sktanmoy Active Member Licensed User Longtime User Feb 3, 2013 #7 Erel said: Another option: Code: Copy Dim list1 As List list1.Initialize2(Days) Dim i As Int = list1.IndexOf("Friday") Click to expand... More flexible Upvote 0
Erel said: Another option: Code: Copy Dim list1 As List list1.Initialize2(Days) Dim i As Int = list1.IndexOf("Friday") Click to expand... More flexible