Posts: 99
Threads: 3
Joined: Apr 2022
Reputation:
10
(11-18-2022, 12:36 AM)SMcNeill Wrote: (11-18-2022, 12:27 AM)bplus Wrote: Code: (Select All) a$ = "12345"
swapLetters a$, 3, 5
Print a$
swapLetters a$, 1, 4
Print a$
Sub swapLetters (a$, n, m)
t$ = Mid$(a$, n, 1)
Mid$(a$, n, 1) = Mid$(a$, m, 1)
Mid$(a$, m, 1) = t$
End Sub
You might want to swap to ASC over MID$, due to the speed and performance difference between the two commands. Letter swapping is usually something which ends up getting called inside loops, and it could really make a difference in how quickly the overall program performs here.
(11-18-2022, 02:49 PM)mnrvovrfc Wrote: (11-18-2022, 12:36 AM)SMcNeill Wrote: You might want to swap to ASC over MID$, due to the speed and performance difference between the two commands. "ASC" might make a good keyword of the day, "my gosh how it's grown" or "not if you went to Dartmouth" or something like that.
It's definitely my keyword of the day. I'm gonna drag my ASC back to the Wiki.
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
Yeah without ASC what's Pete going to joke about?
b = b + ...
Posts: 1,616
Threads: 157
Joined: Apr 2022
Reputation:
77
Actually, when Rob started work on what got officially got labeled as _KEYHIT, he was batting around the idea and posted a proposal to name it _HITKEY. That came to an abrupt end when I replied... "Is there and "S" Pat? Besides, it sounded way too Russian.
Pete
And now, back to the future!
Posts: 456
Threads: 63
Joined: Apr 2022
Reputation:
10
I still almost always start use of _keyhit by writing it as _hitkey, before correcting it ! Now I think I'll pay more attention!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Posts: 1,616
Threads: 157
Joined: Apr 2022
Reputation:
77
(11-19-2022, 12:12 AM)PhilOfPerth Wrote: I still almost always start use of _keyhit by writing it as _hitkey, before correcting it ! Now I think I'll pay more attention!
Glad to be of help, anyway I can!
Pete
|