VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
222 stars 16 forks source link

Array.IndexOf always returns 0 when it found the first element #37

Closed dynamicboy closed 1 month ago

dynamicboy commented 7 months ago

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

VBAndCs commented 7 months ago

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 GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/37, or unsubscribehttps://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.comhttps://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail