Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CommandButton1_Click()
- Dim text, out As String
- Dim k, n, latinCount, nonLatinCount, r, t, p As Integer
- Dim textArray() As String
- Dim latinPositions(), nonLatinPositions() As Variant
- latinCount = 0: nonLatinCount = 0: r = 0: t = 0: p = 0
- text = ReadFromFile("Текст1.txt")
- n = Len(text)
- ReDim textArray(n - 1)
- ReDim latinPositions(n - 1)
- ReDim nonLatinPositions(n - 1)
- For k = 0 To n - 1
- textArray(k) = Mid(a, k + 1, 1)
- Next k
- For k = 0 To n - 1
- If textArray(k) Like "[A-Z]" Or textArray(k) Like "[a-z]" Then
- latinCount = latinCount + 1
- latinPositions(r) = k
- r = r + 1
- ElseIf textArray(k) Like " " Or textArray(k) Like "." Then
- p = p + 1
- Else
- nonLatinCount = nonLatinCount + 1
- nonLatinPositions(t) = k
- t = t + 1
- End If
- Next k
- If latinCount >= 1 Then
- For n = 0 To (latinCount - 1)
- textArray(latinPositions(n)) = "4"
- Next n
- Else
- For n = 0 To (nonLatinCount - 1)
- textArray(nonLatinPositions(n)) = "4"
- Next n
- End If
- For k = 0 To Len(text) - 1
- out = out & textArray(k)
- Next k
- ' MsgBox (d)
- Call WriteToFile("Текст2.txt", out)
- MsgBox(d)
- End Sub
- Private Sub IsMoreLatins(ByRef text() As String)
- For k = 0 To n - 1
- If textArray(k) Like "[A-Z]" Or textArray(k) Like "[a-z]" Then
- latinCount = latinCount + 1
- latinPositions(r) = k
- r = r + 1
- ElseIf textArray(k) Like " " Or textArray(k) Like "." Then
- p = p + 1
- Else
- nonLatinCount = nonLatinCount + 1
- nonLatinPositions(t) = k
- t = t + 1
- End If
- Next k
- End Sub
- Private Function ReadFromFile(ByRef fileName As String) As String
- Dim fso
- Dim file
- Dim readedString as String
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set file = fso.OpenTextFile(fileName, 1)
- readedString = file.ReadAll
- file.Close
- MsgBox("Input: " & a)
- ReadFromFile = readedString
- End Function
- Private Sub WriteToFile(ByRef fileName As String, ByRef s As String)
- Dim fso
- Dim file
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set file = fso.CreateTextFile(fileName, True, True)
- file.WriteLine(s)
- file.Close
- MsgBox("Output: " & s)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement