Home > C# > Formatpastcode numeric

Formatpastcode numeric


Private Sub Command1_Click()
FormatPasteCode rtb.Text, 1
End Sub
Private Sub FormatPasteCode(str As String, currentpos As Integer)
Dim i As Integer
Dim oldPos As Integer
Dim str1 As String
i = currentpos
oldPos = currentpos
Do While i <= Len(str)
If i <> Len(str) Then
If Mid(str, i, 1) = ” ” Or Mid(str, i, 1) = vbTab Then
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
oldPos = i
ElseIf Mid(str, i, 1) = vbCr Then
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
oldPos = i + 1
End If
i = i + 1
Else
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
Exit Do
End If
Loop
End Sub

Private Sub ColorWord(rtb As RichTextBox, start As Integer, length As Integer, color As Long)
Dim oldPos As Integer
oldPos = rtb.SelStart
rtb.SelStart = start
rtb.SelLength = length
rtb.SelColor = color
End Sub

Private Sub Form_Resize()
rtb.Width = ScaleWidth – 800
rtb.Height = ScaleHeight – 800
End Sub

Categories: C#
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: