Dim jb As Integer
Dim ksks() As Single = {40, 50, 50, 6, 7, 8, 50}
jb = Array.IndexOf(ksks, 6)
Debug.Print(jb)
jb returns -1 no matter what number I use that is clearly in the array.
Comments on ‘’ Array.IndexOf help ‘’ ( 1 )
0
Says:
Array.IndexOf gives you the index of any element present in your array. Let's write a small code here:
[code]int[] array = new int[6];
array[0] = 1;
array[1] = 3;
array[2] = 5;
array[3] = 7;
array[4] = 8;
array[5] = 9;
int index1 = Array.IndexOf(array, 9);[/code]
Now when you run it, it will give you 5 as an answer because 5 is the index of value 9. Its giving you -1 because the value whose index you are trying to check is not present in your array. :)
Reply
[/code]
Now when you run it, it will give you 5 as an answer because 5 is the index of value 9. Its giving you -1 because the value whose index you are trying to check is not present in your array.[code]int[] array = new int[6]; array[0] = 1; array[1] = 3; array[2] = 5; array[3] = 7; array[4] = 8; array[5] = 9; int index1 = Array.IndexOf(array, 9);