-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module1.bas
744 lines (698 loc) · 22.4 KB
/
Module1.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
Attribute VB_Name = "Module1"
Option Explicit
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public Type CUSTREP
nSearch As String
nReplace As String
End Type
Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Const WM_USER = &H400
Public Const TRAY_CALLBACK = (WM_USER + 101&)
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const NIM_MODIFY = &H1
Public Const NIM_ADD = &H0&
Public Const NIM_DELETE = &H2&
Public Const GWL_WNDPROC = (-4&)
Public Const WM_DRAWCLIPBOARD = &H308
Public Const CF_TEXT = 1
Public Const CF_UNICODETEXT = 13
Public Const GMEM_FIXED = 0
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4
Public Const MAX_HIST_SIZE = 30
Private Const WM_HOTKEY = &H312
Private Const WM_ACTIVATEAPP = &H1C
Public prev As Long
Public MyString As String
Public ScanClip As Boolean
Public WorkingNow As Boolean
Public CurPz As Long
Public OuStr As String
Public b As String
Public SMode As Integer
Public UsePauseMode As Boolean
Public OnPauseNow As Boolean
Public RESlovar2 As Boolean
Public customRep() As CUSTREP
Public UseCustomRep As Boolean
Public ch4b As Boolean
Public SwapSW As Boolean
Public UseHistory As Boolean
Public ePiksa As Picture
Public dPiksa As Picture
Public HistData As New Collection
Public iClip As New myClip
Sub Main()
If App.PrevInstance Then End
ch4b = True
ScanClip = True
SwapSW = False
UsePauseMode = True
UseHistory = True
WorkingNow = False
RESlovar2 = False
UseCustomRep = False
ReDim customRep(1 To 1)
SMode = 1
Set ePiksa = LoadResPicture(1, vbResIcon)
Set dPiksa = LoadResPicture(2, vbResIcon)
Load frmMain
End Sub
Public Function WinProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim errStick As Integer
#If dbg = 1 Then
On Error GoTo ErrorHandler
#End If
WinProc = CallWindowProc(prev, hwnd, Msg, wParam, lParam)
Select Case Msg
Case TRAY_CALLBACK 'Tray icon
If lParam = 517 Then
With frmMain
.cms(30).Visible = UseHistory
If UseHistory Then .LoadHistory
SetForegroundWindow frmMain.hwnd
.PopupMenu .cmm, , , , .cms(40)
End With
End If
'== Debug ==
errStick = 1
'===========
If lParam = 513 Then 'LBDown
ScanClip = False
WorkingNow = True
iClip.Clear
iClip.SetText MyString
WorkingNow = False
DoEvents
If frmMain.cms(1).Caption = "Отключить" _
Then ScanClip = True
End If
Case WM_DRAWCLIPBOARD 'Clipboard
If WorkingNow Then Exit Function
'== Debug ==
errStick = 2
'===========
If UseHistory Then
MyString = iClip.getText
If Len(MyString) <> 0 Then
If HistData.Count > 0 Then HistData.Add MyString, , 1 _
Else HistData.Add MyString
If HistData.Count > MAX_HIST_SIZE Then
HistData.Remove MAX_HIST_SIZE + 1
Else
Load frmMain.cmhist(HistData.Count)
frmMain.cmhist(HistData.Count).Visible = True
End If
End If
End If
'== Debug ==
errStick = 3
'===========
If ScanClip Then
ScanClip = False
WorkingNow = True
MyString = iClip.getText
If (Len(MyString) <> 0) And (Not IsExeption) Then
RunString
If UseCustomRep Then RunCustom
'== Debug ==
errStick = 5
'===========
iClip.Clear
iClip.SetText OuStr
End If
ScanClip = True
WorkingNow = False
Else
'== Debug ==
errStick = 4
'===========
If frmMain.cms(5).Checked Then
WorkingNow = True
If (Len(iClip.getText) <> 0) Then
MyString = iClip.getText
OuStr = MyString
If UseCustomRep Then RunCustom
iClip.Clear
iClip.SetText OuStr
End If
WorkingNow = False
End If
End If
Case WM_HOTKEY
Select Case wParam
Case Is < 5: frmMain.cmode_Click CInt(wParam)
Case 5: frmMain.cms_Click 1
Case 6: RefreshSysIcon
End Select
End Select
#If dbg = 1 Then
ErrorHandler:
If Err.Number <> 0 Then
MsgBox "Function: WinProc" & vbCrLf & "Error:" & Err.Number & vbCrLf & Err.Description & vbCrLf & "Tag: " & CStr(errStick)
Err.Clear
End If
#End If
End Function
Public Sub RunString()
Dim tb As String
#If dbg = 1 Then
On Error GoTo ErrorHandler
#End If
OuStr = vbNullString
CurPz = 1
OnPauseNow = False
Do While CurPz <= Len(MyString)
tb = Mid(MyString, CurPz, 1)
If (tb = "`") And (UsePauseMode) Then
OnPauseNow = Not OnPauseNow
tb = ""
End If
If Not OnPauseNow Then
Select Case SMode
Case 1: If RESlovar2 Then GetBukER_2 LCase(tb) Else GetBukER LCase(tb)
Case 2: GetBukRE LCase(tb)
Case 3: PerenaborER LCase(tb)
Case 4: PerenaborRE LCase(tb)
Case 5: GetBukEH (tb) 'Experemental mode
End Select
End If
If LCase(tb) <> tb Then
If Len(b) > 1 Then
b = UCase(Left(b, 1)) & Right(b, Len(b) - 1)
Else
b = UCase(b)
End If
End If
If OnPauseNow Then OuStr = OuStr & tb _
Else OuStr = OuStr & b
SkipOne
Loop
#If dbg = 1 Then
ErrorHandler:
If Err.Number <> 0 Then
MsgBox "Function: RunString" & vbCrLf & "Error:" & Err.Number & vbCrLf & Err.Description
Err.Clear
End If
#End If
End Sub
Private Sub GetBukER(ib As String)
Dim tb As String * 1, i As Long, j As Long
Select Case ib
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
Else
b = Mid(MyString, CurPz, i - CurPz)
End If
If (IsNumeric(b)) And (b <> "4") And (b <> "4,") Then
CurPz = CurPz + Len(b) - 1
Else
If ch4b And (ib = "4") Then b = "ч" Else b = ib
End If
Case "a": b = "а"
Case "b": b = "б"
Case "c"
b = "ц"
If Chr(ViewNext) = "h" Then
b = "ч"
SkipOne
End If
Case "d": b = "д"
Case "e": b = "е"
Case "f"
If LCase(Mid(MyString, CurPz, 4)) = "ftp:" Then
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
b = "ф"
End If
Case "g": b = "г"
Case "h"
If LCase(Mid(MyString, CurPz, 4)) = "http" Then
i = InStr(CurPz, MyString, " ")
j = InStr(CurPz, MyString, vbCrLf)
If (j < i) And (j <> 0) Then i = j
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
b = "х"
End If
Case "i": b = "и"
Case "j": b = "ж"
Case "k": b = "к"
Case "l": b = "л"
Case "m": b = "м"
Case "n": b = "н"
Case "o": b = "о"
Case "p": b = "п"
Case "r": b = "р"
Case "s"
b = "с"
If Chr(ViewNext) = "h" Then
If SwapSW Then b = "щ" Else b = "ш"
SkipOne
End If
Case "t": b = "т"
Case "u": b = "у"
Case "v": b = "в"
Case "w"
If LCase(Mid(MyString, CurPz, 4)) = "www." Then
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
If SwapSW Then b = "ш" Else b = "щ"
End If
Case "x": b = "х"
Case "y"
tb = Chr(ViewNext)
Select Case tb
Case "a"
b = "я"
SkipOne
Case "e"
b = "э"
SkipOne
Case "i"
b = "ы"
SkipOne
Case "o"
b = "ё"
SkipOne
Case "u"
b = "ю"
SkipOne
Case Else
b = "й"
End Select
Case "z": b = "з"
Case "'"
b = "ь"
If Chr(ViewNext) = "'" Then
b = "ъ"
SkipOne
End If
Case "^": b = "Ь"
Case Else: b = ib
End Select
End Sub
Private Sub GetBukER_2(ib As String)
Dim tb As String * 1, i As Integer
Select Case ib
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
Else
b = Mid(MyString, CurPz, i - CurPz)
End If
If (IsNumeric(b)) And (b <> "4") And (b <> "4,") Then
CurPz = CurPz + Len(b) - 1
Else
If ch4b And (ib = "4") Then b = "ч" Else b = ib
End If
Case "a": b = "а"
Case "b": b = "б"
Case "c"
b = "ц"
If Chr(ViewNext) = "h" Then
b = "ч"
SkipOne
End If
Case "d": b = "д"
Case "e"
b = "е"
If Chr(ViewNext) = "h" Then
b = "э"
SkipOne
End If
Case "f"
If LCase(Mid(MyString, CurPz, 4)) = "ftp:" Then
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
b = "ф"
End If
Case "g"
b = "г"
If Chr(ViewNext) = "h" Then
b = "ж"
SkipOne
End If
Case "h"
If LCase(Mid(MyString, CurPz, 4)) = "http" Then
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
b = "х"
End If
Case "i": b = "и"
Case "j": b = "й"
Case "k": b = "к"
Case "l": b = "л"
Case "m": b = "м"
Case "n": b = "н"
Case "o": b = "о"
Case "p": b = "п"
Case "r": b = "р"
Case "s"
b = "с"
If Chr(ViewNext) = "h" Then
If SwapSW Then b = "щ" Else b = "ш"
SkipOne
End If
Case "t": b = "т"
Case "u": b = "у"
Case "v": b = "в"
Case "w"
If LCase(Mid(MyString, CurPz, 4)) = "www." Then
i = InStr(CurPz, MyString, " ")
If i = 0 Then
b = Mid(MyString, CurPz, Len(MyString) - CurPz + 1)
CurPz = Len(MyString)
Else
b = Mid(MyString, CurPz, i - CurPz)
CurPz = i - 1
End If
Else
If SwapSW Then b = "ш" Else b = "щ"
End If
Case "x": b = "х"
Case "y"
tb = Chr(ViewNext)
Select Case tb
Case "o"
b = "ё"
SkipOne
Case "u"
b = "ю"
SkipOne
Case "a"
b = "я"
SkipOne
Case Else
b = "ы"
End Select
Case "z": b = "з"
Case "'"
b = "ь"
If Chr(ViewNext) = "'" Then
b = "ъ"
SkipOne
End If
Case Else: b = ib
End Select
End Sub
Private Sub GetBukRE(ib As String)
Select Case ib
Case "а": b = "a"
Case "б": b = "b"
Case "в": b = "v"
Case "г": b = "g"
Case "д": b = "d"
Case "е": b = "e"
Case "ё": b = "yo"
Case "ж": b = "j"
Case "з": b = "z"
Case "и": b = "i"
Case "й": b = "y"
Case "к": b = "k"
Case "л": b = "l"
Case "м": b = "m"
Case "н": b = "n"
Case "о": b = "o"
Case "п": b = "p"
Case "р": b = "r"
Case "с": b = "s"
Case "т": b = "t"
Case "у": b = "u"
Case "ф": b = "f"
Case "х": b = "x"
Case "ц": b = "c"
Case "ч": b = "ch"
Case "ш": b = "sh"
Case "щ": b = "w"
Case "ь": b = "'"
Case "ы": b = "yi"
Case "ъ": b = "''"
Case "э": b = "ye"
Case "ю": b = "yu"
Case "я": b = "ya"
Case Else: b = ib
End Select
End Sub
Private Sub PerenaborER(ib As String)
Select Case ib
Case "q": b = "й"
Case "w": b = "ц"
Case "e": b = "у"
Case "r": b = "к"
Case "t": b = "е"
Case "y": b = "н"
Case "u": b = "г"
Case "i": b = "ш"
Case "o": b = "щ"
Case "p": b = "з"
Case "[": b = "х"
Case "{": b = "Х"
Case "]": b = "ъ"
Case "}": b = "Ъ"
Case "a": b = "ф"
Case "s": b = "ы"
Case "d": b = "в"
Case "f": b = "а"
Case "g": b = "п"
Case "h": b = "р"
Case "j": b = "о"
Case "k": b = "л"
Case "l": b = "д"
Case ";": b = "ж"
Case ":": b = "Ж"
Case "'": b = "э"
Case Chr(34): b = "Э"
Case "z": b = "я"
Case "x": b = "ч"
Case "c": b = "с"
Case "v": b = "м"
Case "b": b = "и"
Case "n": b = "т"
Case "m": b = "ь"
Case ",": b = "б"
Case "<": b = "Б"
Case ".": b = "ю"
Case ">": b = "Ю"
Case "/": b = "."
Case "?": b = ","
Case Else: b = ib
End Select
End Sub
Private Sub PerenaborRE(ib As String)
Select Case ib
Case "ё": b = "`"
Case "й": b = "q"
Case "ц": b = "w"
Case "у": b = "e"
Case "к": b = "r"
Case "е": b = "t"
Case "н": b = "y"
Case "г": b = "u"
Case "ш": b = "i"
Case "щ": b = "o"
Case "з": b = "p"
Case "х": b = "["
Case "ъ": b = "]"
Case "ф": b = "a"
Case "ы": b = "s"
Case "в": b = "d"
Case "а": b = "f"
Case "п": b = "g"
Case "р": b = "h"
Case "о": b = "j"
Case "л": b = "k"
Case "д": b = "l"
Case "ж": b = ";"
Case "э": b = "'"
Case "я": b = "z"
Case "ч": b = "x"
Case "с": b = "c"
Case "м": b = "v"
Case "и": b = "b"
Case "т": b = "n"
Case "ь": b = "m"
Case "б": b = ","
Case "ю": b = "."
Case ".": b = "/"
Case ",": b = "?"
Case Else: b = ib
End Select
End Sub
Private Sub GetBukEH(ib As String)
Select Case ib
Case "a": b = ChrW$(1488) 'Alef
Case "b": b = ChrW$(1489) 'Bet
Case "g": b = ChrW$(1490) 'Gimel
Case "d": b = ChrW$(1491) 'Dalet
Case "x": b = ChrW$(1492) 'Hei
Case "v", "u", "o": b = ChrW$(1493) 'Vav
Case "z": b = ChrW$(1494) 'Zain
Case "h": b = ChrW$(1495) 'Het
Case "T": b = ChrW$(1496) 'Tet
Case "i": b = ChrW$(1497) 'Iud
Case "K", "H" 'Xaf
b = ChrW$(1499)
If Chr(ViewNext) = " " Then b = ChrW$(1498)
Case "l": b = ChrW(1500) 'lamed
Case "m" 'Mem
b = ChrW$(1502)
If Chr(ViewNext) = " " Then b = ChrW$(1501)
Case "n" 'Nun
b = ChrW$(1504)
If Chr(ViewNext) = " " Then b = ChrW$(1503)
Case "s" 'Sin, shin
b = ChrW$(1505)
If Chr(ViewNext) = "h" Then
b = ChrW$(1513)
SkipOne
End If
Case "A": b = ChrW$(1506) 'Ain
Case "p", "f" 'Pei, fei
b = ChrW$(1508)
If Chr(ViewNext) = " " Then b = ChrW$(1507)
Case "c" 'Tzadik
b = ChrW$(1510)
If Chr(ViewNext) = " " Then b = ChrW$(1509)
Case "k": b = ChrW$(1511) 'Kuf
Case "r": b = ChrW$(1512) 'Reish
Case "t": b = ChrW$(1514) 'Tav
Case "e": b = vbNullString
Case Else: b = ib
End Select
End Sub
Private Function ViewNext() As Integer
Dim tb As String * 1
tb = Mid(MyString, CurPz + 1, 1)
If tb = "" Then tb = " "
ViewNext = Asc(LCase(tb))
End Function
Private Function SkipOne()
CurPz = CurPz + 1
End Function
Public Function SetTrayIcon(Mode As Long, hwnd As Long, Icon As Long, tip As String) As Long
Dim nidTemp As NOTIFYICONDATA
nidTemp.cbSize = Len(nidTemp)
nidTemp.hwnd = hwnd
nidTemp.uID = 0&
nidTemp.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nidTemp.uCallbackMessage = TRAY_CALLBACK
nidTemp.hIcon = Icon
nidTemp.szTip = tip & Chr$(0)
SetTrayIcon = Shell_NotifyIconA(Mode, nidTemp)
End Function
Public Function IsExeption() As Boolean
Dim tmp As String
tmp = LCase(Trim(MyString))
IsExeption = False
IsExeption = IsNumeric(MyString)
If Mid(tmp, 2, 2) = ":\" Then IsExeption = True
End Function
Sub RefreshSysIcon()
SetTrayIcon NIM_DELETE, frmMain.hwnd, 0, vbNullString
SetTrayIcon NIM_ADD, frmMain.hwnd, ePiksa.Handle, App.Title
If Not ScanClip Then _
SetTrayIcon NIM_MODIFY, frmMain.hwnd, dPiksa.Handle, App.Title
End Sub
Private Sub str_replace(ByVal Find As String, ByVal Replace As String, ByRef Expression As String, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare)
On Error Resume Next
Dim l As Long
Dim lenR As Long
Dim p1 As Long
Dim p2 As Long
Dim p21 As Long
Dim s As String
l = Len(Find)
If (l = 0) Then Exit Sub
lenR = Len(Replace)
If (lenR = l) Then
p1 = 1
p2 = InStr(p1, Expression, Find, Compare)
Do While (p2)
Mid$(Expression, p1) = Mid$(Expression, p1, p2 - p1)
Mid$(Expression, p2) = Replace
p1 = p2 + l
p2 = InStr(p1, Expression, Find, Compare)
Loop
Exit Sub
ElseIf (lenR > l) Then
s = Space$(Len(Expression) + (Len(Expression) \ l) * (lenR - l))
Else
s = Space$(Len(Expression))
End If
p21 = 1
p1 = 1
p2 = InStr(p1, Expression, Find, Compare)
Do While (p2)
Mid$(s, p21) = Mid(Expression, p1, p2 - p1)
p21 = p21 + p2 - p1
Mid$(s, p21) = Replace
p21 = p21 + lenR
p1 = p2 + l
p2 = InStr(p1, Expression, Find, Compare)
Loop
Mid$(s, p21) = Mid$(Expression, p1)
p21 = p21 + Len(Mid$(Expression, p1))
s = Left$(s, p21 - 1)
Expression = s
End Sub
Private Sub RunCustom()
Dim j As Long
For j = LBound(customRep) To UBound(customRep)
str_replace customRep(j).nSearch, customRep(j).nReplace, OuStr
Next
End Sub