Results 1 to 2 of 2

Thread: String to RichText? (Solved)

  1. #1

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Resolved String to RichText? (Solved)

    I have a string that has the following symbols:
    • *-O
    • ->
    • -v


    (This is an old project I am trying to code better)
    I put this text in a richtextbox and loop through it changing the *-O into an M using the font "Wingdings" with size 10 and color vbBlue...

    This *-O appears a lot in the string and so it makes the form load after a lot of time... I was wondering if there was an easier (and faster) way to do this in order to display the text correctly in the RichTextBox.

    I appreciate your help

    P.S. I want to change the -> to g using the font "Wingdings 3", size 10 and color vbBlack and then-v to ? using the font "Wingdings 3", size 10 and color vbBlack (just in case you were wondering about it)
    Last edited by Tec-Nico; Oct 3rd, 2004 at 01:49 PM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  2. #2

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Nevermind, I found a way:

    VB Code:
    1. Public Function changeDefaultFormat(strReplaced As String) As String
    2.  changeDefaultFormat = "{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil\fcharset2 Wingdings;}{\f2\fnil\fcharset2 Wingdings 3;}}" & vbNewLine
    3.  changeDefaultFormat = changeDefaultFormat & "{\colortbl ;\red0\green0\blue255;\red0\green0\blue0;}" & vbNewLine
    4.  changeDefaultFormat = changeDefaultFormat & "\viewkind4\uc1\pard\lang2058\f0\fs17" & vbNewLine
    5.  
    6.  strReplaced = Replace(strReplaced, vbNewLine, "\par " & vbNewLine)
    7.  strReplaced = Replace(strReplaced, "*-O", "\cf1\f1\fs20 M\cf0\f0\fs17")
    8.  strReplaced = Replace(strReplaced, "->", "\cf2\f2\fs20 g\cf0\f0\fs17")
    9.  strReplaced = Replace(strReplaced, "-v", "\cf2\f2\fs20 ?\cf0\f0\fs17")
    10.  
    11.  changeDefaultFormat = changeDefaultFormat & strReplaced
    12. End Function

    Thanks anyway!
    Last edited by Tec-Nico; Aug 24th, 2004 at 11:50 PM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width