Dim TabsAsSpaces As Boolean
TabsAsSpaces = True 'Use spaces instead of tabs
Dim AmountOfSpacePerTab As Integer
AmountOfSpacePerTab = 4 'How many spaces to use in place of one tab
Dim AutoTab As Boolean
AutoTab = True 'Automatically indent
Dim temp As String, PrevLineSpaces As Integer, PrevLineTabs As Integer
temp = ""
PrevLineSpaces = 0
PrevLineTabs = 0
If TabsAsSpaces Then
If KeyAscii = 9 Then
txtDocument.Text = Left(txtDocument.Text, Len(txtDocument.Text) - 1)
txtDocument.Text = txtDocument.Text & String(AmountOfSpacePerTab, "|")
End If
If AutoTab Then
If KeyAscii = 13 Then
temp = ""
Dim II As Integer
'temp = Convert.ToString(this.Lines.GetValue(this.GetLineFromCharIndex(this.SelectionStart - 1)))
'For II = Len(txtDocument.Text) To 1 Step -2
' If Not Mid(txtDocument.Text, II - 1, 2) = vbCrLf Then
' temp = temp & Mid(txtDocument.Text, II - 1, 2)
' Else
' Exit For
' End If
'Next II
For II = 1 To Len(temp)
If Mid(temp, II, 1) = vbTab Then
PrevLineTabs = PrevLineTabs + 1
ElseIf Mid(temp, II, 1) = " " Then
PrevLineSpaces = PrevLineSpaces + 1
Else: Exit For
End If
Next II
If Not PrevLineTabs = 0 Then
For II = 1 To PrevLineTabs
txtDocument.Text = txtDocument.Text & vbTab
Next II
End If
If Not PrevLineSpaces = 0 Then
For II = 1 To PrevLineSpaces
'txtDocument.Text = txtDocument.Text & " "
Next II
End If
PrevLineSpaces = 0
PrevLineTabs = 0
End If
End If
End If