![]() |
Instr to count occurrences - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Instr to count occurrences (/showthread.php?tid=3646) |
Instr to count occurrences - PhilOfPerth - 04-29-2025 Is there, or could there be, a function that returns the number of occurrences of a character (or substring) in a string? Like Instr, but instead of position, returns the times the substring occurs. I know we can use Instr with a position number to repeat the search, but can we do this in a simpler way? RE: Instr to count occurrences - bplus - 04-29-2025 Code: (Select All) Option _Explicit RE: Instr to count occurrences - PhilOfPerth - 04-29-2025 (04-29-2025, 02:10 AM)bplus Wrote: Thanks bplus. That's much more compact than what I was using Shame there's not an inbuilt function, for lazy bods like me though. ![]() RE: Instr to count occurrences - SMcNeill - 04-29-2025 Try this: https://qb64phoenix.com/forum/showthread.php?tid=3629 Play around with the String.Find RE: Instr to count occurrences - mdijkens - 04-29-2025 (04-29-2025, 02:52 AM)SMcNeill Wrote: Try this: https://qb64phoenix.com/forum/showthread.php?tid=3629Also much more efficient. Mid$ is a very expensive function to use in this scenario RE: Instr to count occurrences - TempodiBasic - 04-29-2025 Hi taken from wiki INSTR example, ![]() Code: (Select All)
|