Основы офисного программирования и документы Word


Dim Sym As String, Sym1


Public Sub CodeDA() Const ALU = "бвчздецъйклмнопртуфхжигюыэящшьас" Const AL = "БВЧЗДЕЦЪЙКЛМНОПРТУФХЖИГЮЫЭЯЩШЬАС" Dim Sym As String, Sym1 As Variant Dim Index As Integer Dim Result As String 'Переменные, задающие начальное время участка процедуры Dim Start1 As Single, Start2 As Single, Start3 As Single, Start4 As Single Dim Start5 As Single, Start6 As Single, Start7 As Single, Start8 As Single 'Переменные, накапливающие время выполнения участка программы Dim TALL As Single, TSelect As Single, TIndex1 As Single, TIndex2 As Single Dim TSym1 As Single, TSym2 As Single, TForEach As Single
Dim i As Integer Start1 = Timer Result = "" Start2 = Timer 'Два способа организации цикла! 'For Each Sym1 In Selection.Characters For i = 1 To Selection.Characters.Count Sym1 = Selection.Characters(i)
Start3 = Timer Sym = Sym1 'Два способа организации разбора случаев 'Select Case Sym 'Case "А" To "Я" 'русская буква верхнего регистра If Sym >= "А" And Sym <= "Я" Then
Start5 = Timer Index = Asc(Sym) - Asc("А") + 1 TIndex1 = TIndex1 + Timer - Start5 Start6 = Timer Sym = Mid(ALU, Index, 1) TSym1 = TSym1 + Timer - Start6 'End If 'Case "а" To "я" 'русская буква нижнего регистра ElseIf Sym >= "а" And Sym <= "я" Then Start7 = Timer Index = Asc(Sym) - Asc("а") + 1 TIndex2 = TIndex2 + Timer - Start7 Start8 = Timer Sym = Mid(AL, Index, 1) TSym2 = TSym2 + Timer - Start8 'End Select End If TSelect = TSelect + Timer - Start3 Result = Result + Sym Next TForEach = TForEach + Timer - Start2 Selection.LanguageID = wdRussian Selection.TypeText Result TALL = TALL + Timer - Start1 Debug.Print "TAll = ", TALL Debug.Print "TForEach = ", TForEach Debug.Print "TSelect = ", TSelect Debug.Print "TIndex1 = ", TIndex1 Debug.Print "TIndex2 = ", TIndex2 Debug.Print "TSym1 = ", TSym1 Debug.Print "TSym2 = ", TSym2
End Sub
Листинг 2.23.
Закрыть окно
Содержание раздела