Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alphabetical sort of characters within a string.
#50
(04-27-2024, 03:31 PM)SMcNeill Wrote:
(04-27-2024, 01:46 PM)bplus Wrote:
(04-27-2024, 02:42 AM)SMcNeill Wrote: Bada Bing!!  You're welcome, oh ye of little faith.  Big Grin

Now your code is beginning to look more like the one which I shared from the beginning for you.  it would also complain of the same "invalid value"

Big Grin  Big Grin Wink

+1 ok this has been quite an adventure past couple days

i would probably have been onto it quicker had you shared the file you were using with code in zip but still a hard won lesson will be likely remembered better/longer.

i wonder if that trick will help the other version of anaCode with all the letter counts or PeteCode ?

I didn't have your file, but I figured you'd just swap dictionary names for testing purposes.  Big Grin

Guess that'll show me!   Big Grin

coulda, shoulda, must of been feel'n lazy...

holy cow! Bind$() puts PeteCode3$ back on top!
compare
Code: (Select All)
Function petecode2$ (la$)
    Dim rtn$, i%, seed%, j%, a$
    a$ = UCase$(la$)
    rtn$ = Space$(Len(a$))
    For i% = 65 To 90
        seed% = InStr(a$, Chr$(i%))
        While seed%
            j% = j% + 1
            Mid$(rtn$, j%) = Chr$(i%)
            seed% = InStr(seed% + 1, a$, Chr$(i%))
        Wend
    Next
    petecode2$ = _Trim$(rtn$)
End Function

Function petecode3$ (la$)
    Dim rtn$, i%, seed%, j%, a$
    Dim t$(1 To Len(la$))
    a$ = UCase$(la$)
    For i% = 65 To 90
        seed% = InStr(a$, Chr$(i%))
        While seed%
            j% = j% + 1
            t$(j%) = Chr$(i%)
            seed% = InStr(seed% + 1, a$, Chr$(i%))
        Wend
    Next
    petecode3$ = bind$(t$())
End Function
petecode2$ was already using mid$ trick just not en mass as bind$() does it. you'd think the extra steps to save all the strings into an array to bind and extra call to bind would take longer, but no!

oh got to clean code and run tests with browser off...
b = b + ...
Reply


Messages In This Thread
RE: Alphabetical sort of characters within a string. - by bplus - 04-27-2024, 03:46 PM



Users browsing this thread: 1 Guest(s)