Array.IndexOf always returns 0 when it found the first element
dynamicboy opened this issue · comments
dynamicboy commented
Version:2.8.7
Details:
Small Visual Basic
ArrayGroup1[1] = 1
ArrayGroup1[2] = 2
ArrayGroup1[3] = 3
For I = 0 To 3
Index = Array.IndexOf(ArrayGroup1, I, 1, True)
TW.WriteLine("Index = " + Index)
Next
Output:
Index = 0
Index = 0
Index = 1
Index = 2
Mohammad Hamdy Ghanem commented
I found that I didn't add a test for the IndexOf method, so I did, and fixed this issue. I also hide the Text.GetIndexOf method and added a Text.IndexOf method to be consistent with the Array.IndexOf.
I updated sVB to version 2.8.7.3 and you can now download it:
https://marketplace.visualstudio.com/items?itemName=ModernVBNET.sVBInstaller
and try your code, which by the way can be shorten to this:
```
ArrayGroup1 = {1, 2, 3}
For I = 0 To 3
Index = ArrayGroup1.IndexOf(I, 1, True)
TW.WriteLine("Index = " + Index)
Next
```
Thanks.
…________________________________
From: dynamicboy ***@***.***>
Sent: Friday, December 8, 2023 11:46 PM
To: VBAndCs/sVB-Small-Visual-Basic ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [VBAndCs/sVB-Small-Visual-Basic] Array.IndexOf always returns 0 when it found the first element (Issue #37)
Version:2.8.7
Details:
Small Visual Basic
ArrayGroup1[1] = 1
ArrayGroup1[2] = 2
ArrayGroup1[3] = 3
For I = 0 To 3
Index = Array.IndexOf(ArrayGroup1, I, 1, True)
TW.WriteLine("Index = " + Index)
Next
Output:
Index = 0
Index = 0
Index = 1
Index = 2
—
Reply to this email directly, view it on GitHub<#37>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALQ5MVRIBJFSBWIBBG3CPWLYIORENAVCNFSM6AAAAABANKTBESVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZTGNBUGEYDCNQ>.
You are receiving this because you are subscribed to this thread.
[https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>