Hi, I'm trying to write a program that uses a richtextbox, and does what the VB Enviroment does to keywords, for example:
See how this message board changes the colors of all the keywords and comments? I want my program to do the same, but it's proving a little harder than I thought it would be.Code:Public Sub SelectLineText(EditControl As Control, ByVal nLineNumber As Long) Dim lIndex As Long Dim lc As Long Dim LineBuffer As String 'Ensure Linenumber valid If nLineNumber < 0 Then nLineNumber = 0 lc = GetMaxLines(EditControl.hWnd) If nLineNumber > lc - 1 Then nLineNumber = lc - 1 'Return starting char pos on passed line number lIndex = SendMessageByNum(EditControl.hWnd, EM_LINEINDEX, nLineNumber, 0&) 'Return the length of the passed line number lc = SendMessageByNum(EditControl.hWnd, EM_LINELENGTH, lIndex, 0&) + 1 EditControl.SelStart = lIndex EditControl.SelLength = lc Debug.Print EditControl.SelText End Sub
Has anyone already written a program like this, using a RichTextBox? Please let me knowwww. =)




Reply With Quote