How to resolve the algorithm Abbreviations, automatic step by step in the VBA programming language
How to resolve the algorithm Abbreviations, automatic step by step in the VBA programming language
Table of Contents
Problem Statement
The use of abbreviations (also sometimes called synonyms, nicknames, AKAs, or aliases) can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc.
It would make a list of words easier to maintain (as words are added, changed, and/or deleted) if the minimum abbreviation length of that list could be automatically (programmatically) determined.
For this task, use the list (below) of the days-of-the-week names that are expressed in about a hundred languages (note that there is a blank line in the list). Caveat: The list (above) most surely contains errors (or, at the least, differences) of what the actual (or true) names for the days-of-the-week.
To make this Rosetta Code task page as small as possible, if processing the complete list, read the days-of-the-week from a file (that is created from the above list).
Notes concerning the above list of words
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Abbreviations, automatic step by step in the VBA programming language
Source code in the vba programming language
Function MinimalLenght(strLine As String) As Integer
Dim myVar As Variant, I As Integer, Flag As Boolean, myColl As Collection, Count As Integer
myVar = Split(strLine, " ")
Count = 0
Do
Set myColl = New Collection
Count = Count + 1
On Error Resume Next
Do
myColl.Add Left$(myVar(I), Count), Left$(myVar(I), Count)
I = I + 1
Loop While Err.Number = 0 And I <= UBound(myVar)
Flag = Err.Number = 0
On Error GoTo 0
I = 0
Set myColl = Nothing
Loop While Not Flag
MinimalLenght = Count
End Function
Sub Main_Abbr_Auto()
Dim Nb As Integer, s As String, Result() As String, c As Integer
Nb = FreeFile
Open "C:\Users\" & Environ("Username") & "\Desktop\Abbreviations_Auto.txt" For Input As #Nb
While Not EOF(Nb)
Line Input #Nb, s
If InStr(s, "þ") > 0 Then s = Right(s, Len(s) - 2)
If s <> vbNullString Then
ReDim Preserve Result(c)
Result(c) = Left$(MinimalLenght(s) & " ", 4) & s
Debug.Print Result(c)
c = c + 1
End If
Wend
Close #Nb
End Sub
You may also check:How to resolve the algorithm Roots of a function step by step in the Dart programming language
You may also check:How to resolve the algorithm Wagstaff primes step by step in the Arturo programming language
You may also check:How to resolve the algorithm Kernighans large earthquake problem step by step in the Java programming language
You may also check:How to resolve the algorithm S-expressions step by step in the Ada programming language
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the V (Vlang) programming language