Palog.cls doesn't work. It might be because I havevb5. Sure there isn't another way to do this?
Printable View
Palog.cls doesn't work. It might be because I havevb5. Sure there isn't another way to do this?
I just tested it, and it works fine, but it might be that the RTF box, that comes with VB5 doesn't support RTF 1.6.
There might be usercontrols out there, that can do it for you. That is my only other solution.
You could however also see Microsofts homepage under RTF documentation, it might tell you which version the vb5 control supports, and then you can just alter the code so it works with the older version.
I have included a small test project, which works.
A few scraps of code based on RTB
Code:' load a text file into a richtextbox from a filebox
' load a filelistbox [File1] and set it's path
' load a RichTextBox [RichTextBox1} with scrollbars
' and multiline to true
'colorlor certain letters in a richtextbox
'in this example a W is used.
'
'or if you call ColorAll then it colors all letters randomly
'and changes the backcolor of the textbox to black
'
Option Explicit
Public Sub ColorAll()
Dim posEnd As Integer, posStart As Integer
Dim x As Integer, i As Integer, j As Integer
Dim myArr(5)
myArr(0) = vbRed
myArr(1) = vbBlue
myArr(2) = vbYellow
myArr(3) = vbMagenta
myArr(4) = vbGreen
myArr(5) = vbCyan
RichTextBox1.BackColor = vbBlack
x = 0 'start
i = 0 'start
Randomize
For i = 0 To Len(RichTextBox1.Text)
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
posStart = i
j = Int(Rnd * 5) + 1
RichTextBox1.SelColor = myArr(j)
Next i
End Sub
Public Sub colorize()
Dim posEnd, posStart, x, i As Integer
x = 0
i = 0
For i = 0 To Len(RichTextBox1.Text)
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
If RichTextBox1.SelText = "S" Then 'start tag
posStart = i
RichTextBox1.SelColor = vbRed
End If
Next i
End Sub
Public Sub MakeColored()
'find the word SELECT in your text box and color it blue
Dim x
For x = 1 To Len(RichTextBox1.Text)
If Mid(RichTextBox1.Text, x, Len("SELECT")) = "SELECT" Then
RichTextBox1.SelStart = x - 1
RichTextBox1.SelLength = Len("SELECT")
RichTextBox1.SelColor = vbBlue
RichTextBox1.SelLength = 0
RichTextBox1.SelColor = vbBlack
x = (x - 1) + Len("SELECT")
Else
RichTextBox1.SelColor = vbBlack
End If
Next x
RichTextBox1.SelStart = Len(RichTextBox1.Text)
End Sub
Private Sub cmdQuit_Click()
Unload Me
End Sub
Private Sub Command1_Click()
Call MakeColored
End Sub
Private Sub Form_Load()
File1.Path = "C:\my documents"
File1.Pattern = "*.txt"
End Sub
Private Sub File1_Click()
RichTextBox1.LoadFile File1.Path & "\" & File1.FileName
End Sub
Highlights File1.
Says--> Variable not Defined