Here is a better looking separator routine.
The beauty of this routine is that it inserts a seperator that looks nice, scrolls properly and the user cannot access. The one problem is that you will have to remove it before saving, but that is easily handled with a call to replace.
Use the above (fixed) colortable function and this new separator routineJust call it like thisVB Code:
Public Sub Separator(rtb As RichTextBox, lColor1 As Long, _ lColor2 As Long, halfWidth As Integer, txtTitle As String) Dim iPos As Long Dim strRTF As String Dim txtTemp As String Dim icolor1 As Integer Dim icolor2 As Integer Dim iUP As Integer With rtb iPos = .SelStart iUP = Int(.SelFontSize) - 1 'bracket selection .SelText = Chr(&H80) & .SelText & Chr(&H81) ' \'80 \'81 strRTF = rtb.TextRTF 'add new colors icolor1 = AddColorToTable(strRTF, lColor1) icolor2 = AddColorToTable(strRTF, lColor2) 'add separator txtTemp = "\par" & _ "\cf" & CStr(icolor1) & "\protect\up" & CStr(iUP) & " " & String(halfWidth, "_") & "\up0" & _ "\cf" & CStr(icolor2) & " " & txtTitle & _ "\cf" & CStr(icolor1) & "\up" & CStr(iUP) & " " & String(halfWidth, "_") & "\up0\cf0" strRTF = Replace(strRTF, "\'80", txtTemp) strRTF = Replace(strRTF, "\'81", "\protect0\cf0\par ") .TextRTF = strRTF .SelStart = iPos End With End SubVB Code:
Separator rtb, vbRed, vbBlue, 20, " Visual Basic Code "




Reply With Quote