Page 3 of 4 FirstFirst 1234 LastLast
Results 81 to 120 of 159

Thread: RichTextBox Tricks and Tips

  1. #81
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: RichTextBox Tricks and Tips

    I am trying to adjust you code to make it an option that can be turned on/off.

    If the user opens the Options form and changes the option from Enabled to Disabled, I am getting the error:
    Object variable or With block variable not set.
    on this line:
    vb Code:
    1. FormSubClass.Unsubclass
    I know what this means, but I'm not too sure how to change this.

    This is because, even if the Enabled option is selected, I don't use this line until certain conditions are met:
    vb Code:
    1. EnableAutoURLDetection RTB
    so the RTB hasn't yet been subclassed.

    Is there some way of checking if the subclassing has happened before I fire this line of code?
    vb Code:
    1. FormSubClass.Unsubclass

    Such as
    Code:
    If Not FormSubClass.Unsubclass Then ....
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  2. #82

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    Actually there is a very simple solution:
    Take the line
    Code:
    Set FormSubClass = New clsSubClass
    from out of the EnableAutoURLDetection subroutine and put it into the Form_Load Event.

  3. #83
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: RichTextBox Tricks and Tips

    Hi

    I am very new to VB6 so please bear with me.

    I have used your Auto URL Detection within my program. When i downloaded your file it worked fine on its own, but as soon as I have intergrated it with mine I seem to have broken it.

    My program still work as it did, and the url changes to a hyperlink where expected, the only bit which does not work is th clicking of the url.

    Can you look over what I have done and see what you make of it

    Thanks
    Attached Files Attached Files

  4. #84

  5. #85
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: RichTextBox Tricks and Tips

    Sorry

    Give me a couple of minutes and i'll repost with them

  6. #86

  7. #87
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: RichTextBox Tricks and Tips

    Martin
    Thanks for your offer of help. What a great site you have got here.

    I have rewritten this part of my program in a single form removing it from my main program in order to send to you for help and in so, I have resolved my issue.

    I have changed my program to look at the SQL Northwind default database. If you change a couple of the records within the orders table on the "Shipname" field to be a url then this seems to work fine.

    I have attached for others to view.
    If you are going to look at the attached please be aware that my coding maybe a little rough around the edges

  8. #88
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: RichTextBox Tricks and Tips

    Attachment
    Attached Files Attached Files

  9. #89
    New Member
    Join Date
    Jul 2007
    Posts
    1

    Re: RichTextBox Tricks and Tips

    I just wanted to add my thanks for some really great tips and also to point out that in post #3, line 8 of SetSuperScript is:

    .SelText = Chr(&H9D) & .SelText & Chr(&H80)

    However, unless I change this to:

    .SelText = Chr(&H9D) & .SelText & Chr(&H81)

    It behaves strangely.

    Thanks again

  10. #90
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    Re: RichTextBox Tricks and Tips

    Thank you for these great RTB tips. I have been using the Tables code you provided. As I'm sure you're aware, there are two basic wrappers for RTB control... riched32.dll and riched20.dll. The tables code behaves differently depending on the wrapper being used. The problems I've noted are:

    1. Text that wraps in a cell does not display properly if riched32.dll (default) is being used. It displays correctly with the newer riched20.dll (ver 4+).

    2. The grid lines of a table created with your code does not print with riched20.dll but does with the older riched32.dll.

    Since MS WordPad uses the riched20.dll (disguised as msftedit.dll) and since the tables format correcly, I too prefer that version. My question is... is there a way to have the grid lines print?

    Thanks, again for your insight and very helpful code!

    Tom

  11. #91
    New Member
    Join Date
    Mar 2002
    Posts
    14

    Re: Full Featured Spell Checker

    Quote Originally Posted by moeur
    Here is a class that provides full spell checking functionality for the RichTextBox. This class has only two methods:
    GetSpellingErrors checks the spelling in all the text of a RTB and returns the number of spelling errors found and marks then all. A right-click on any error brings up a popup menu with suggested changes. If the user selects a change from the menu, then the replacement is made.

    ClearSpelling clears all the marked errors.
    Here is an example of use:
    Code:
    Option Explicit
    Private SpellCheck As clsSpellCheck
    
    Private Sub cmdSpellCheck_Click()
        SpellCheck.GetSpellingErrors RTB
    End Sub
    
    Private Sub cmdStopSpell_Click()
        SpellCheck.ClearSpelling
    End Sub
    
    Private Sub Form_Load()
        Set SpellCheck = New clsSpellCheck
        RTB.LoadFile App.Path & "\recipe.rtf"
    End Sub

    This code also provides an example of several other things.
    • How to implement the EN_LINK notification function of the RichTextBox. This notification is usually used to mark hyperlinks and respond to mouse events over them. I use it to mark spelling errors and to bring up a popup menu of spelling suggestions for the user to select from.
    • I have included a class that is used to create and respond to popup menus. I put this functionality into a class because I wanted all the spell checking functionality contained within a class with none of the code in the form.
    • Also included is my "Cute Little Subclasser" class. I use this class whenever I want subclassing capabilities. When this class is declared WithEvents, the user can write code to respond to Windows messages within the form or class's own module. It also is a little more stable than doing your own subclassing since it always remembers to turn itself off.
    Attached is the source code for all the above mentioned items PLUS a free mispelled recipe!


    Hi there, wanted to try your spell checker but faced some strange issues. I copied over your libraries and imported your form, but for the same actions I am getting error at GetSpellingErrors()

    For Each spError In WordDoc.SpellingErrors

    Error 13 Type mismatch

    whenever there is a misspelled word. If there are no errors, the program works fine. This error only happens to the new 'copied' project, does not happen in your program.

    I have added the components and references, even the dll even though I don't think that is needed. I have added the error image attachment here for clearer understanding (if I had not made myself clear)

    Am I missing something?
    Attached Images Attached Images   
    -scmay-

  12. #92
    New Member
    Join Date
    Oct 2007
    Posts
    1

    Re: Inserting Hyperlinks

    Dear all,

    Has anyone deviced any method / subclass trick for actually changing the default blue color of the RTF EN_LINK hyperlinks? I mean, if I want to display a red hyperlink, is this possible?

    In my research I tried using GetSystemColors and SetSystemColors with index value 26 (Hyperlink) but it seems to have no affect of RichEdit.

  13. #93
    New Member
    Join Date
    Dec 2007
    Posts
    1

    Re: RichTextBox Tricks and Tips

    Hello!

    Thank you very much for the code for the tables in richtextbox, it's the only available on the internet. Unfortunatly i'm using vb.net 2005 and can't convert it correctly to use it in my app. Do you have any library for .net?

    Regards

  14. #94
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: RichTextBox Tricks and Tips

    Hi moeur,

    I ran into an issue. If I enable the autourldetection the selchange event doesn't fire so the line and columns dont get updated in the statusbar as I move the cursor

  15. #95

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    I did verify the problem you see. This is a problem with the Richtext box which we have no control over. But, there is a simple fix:
    Place the code that is in the SelChange Event in both the RTB_Click and RTB_KeyUp events.

  16. #96
    Junior Member
    Join Date
    Feb 2008
    Posts
    31

    Re: RichTextBox Tricks and Tips

    Hi moeur

    Your code is great for inserting pictures into the rich textbox.

    However, i am able to move the images around and resize them. I dont want them to be resized/moved around.

    How can you stop pictures from being moved and resized?

    (NOTE: The locked property of the rich textbox is useless to me, because if Locked is set to TRUE, then you cant even type in the rich textbox).

  17. #97
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: RichTextBox Tricks and Tips

    Hi moeur,

    I think you can solve a little problem for me, back in May last year and in another Forum, I was struggling to help someone who wanted something like a ProgressBar but with text inside it (they were building a Browser and wanted to do like Firefox, I think, the Progress was displayed where the URL was typed.) Anyway, I came up with a RichTextBox solution:
    Code:
    Option Explicit
    '
    ' Example of manipulating RTF in a RichTextBox
    ' to simulate a 'ProgressBar' with imbedded text
    ' (Based on some code I found on the Internet somewhere)
    '
    ' Requires:
    ' Command Button (cmdGo)
    ' RichTextBox (rtb1)
    ' Timer (Timer1)
    '
    ' Tested on XP SP2 and it seems to work OK
    ' Tested on Windows ME and doesn't work
    '
    Private boFinished As Boolean
    Private strOriginalRTF As String
    
    Private Sub cmdGo_Click()
    '
    ' Simulates starting something going
    '
    Timer1.Enabled = True
    End Sub
    
    Private Sub Form_Load()
    Timer1.Enabled = False
    Timer1.Interval = 500
    rtb1.Text = "This is some text"
    End Sub
    
    Private Sub Timer1_Timer()
    '
    ' Simulates 'progress'
    ' Triggers once every half second
    '
    boFinished = UpdateProgress(1)
    If boFinished = True Then
        Timer1.Enabled = False
        rtb1.TextRTF = strOriginalRTF
        rtb1.SelStart = 0
        rtb1.SelLength = 0
    End If
    End Sub
    Private Function UpdateProgress(intColour As Integer) As Boolean
    '
    ' Progressively change the background colour of
    ' each character in the RichTextBox to intColour
    ' Achieved by inserting RTF codes to define a ColorTable
    ' and highlight the selected text.
    '
    ' Returns True when all characters have been processed
    '
    Dim strColour As String
    Dim strRTF As String
    Static intEnd As Integer
    UpdateProgress = False
    '
    ' Save the original TextRTF so it can be
    ' re-set later, increment the character position
    ' and check if we've finsihed yet
    '
    If intEnd = 0 Then strOriginalRTF = rtb1.TextRTF
    intEnd = intEnd + 1
    If intEnd <= Len(rtb1.Text) Then
        '
        ' Select the appropriate number of characters
        ' and make sure they don't appear highlighted
        ' by the selection
        '
        rtb1.SelStart = 0
        rtb1.SelLength = intEnd
        rtb1.SelColor = rtb1.BackColor
        '
        ' Convert the colour to RGB form
        ' and insert leading zeros if required
        '
        strColour = Hex(QBColor(intColour))
        strColour = String(6 - Len(strColour), "0") & strColour
        '
        ' Now build our RTF:
        '
        ' ColorTable:
        '
        strRTF = "{{\colortbl;"
        strRTF = strRTF & "\red" & CInt("&H" & Right(strColour, 2))
        strRTF = strRTF & "\green" & CInt("&H" & Mid(strColour, 3, 2))
        strRTF = strRTF & "\blue" & CInt("&H" & Left(strColour, 2))
        strRTF = strRTF & ";}"
        '
        ' Highlight:
        ' This is the RTF Code used to cause the change in
        ' colour. It uses our ColorTable (Number 1)
        ' (I can't seem to find any documentation on this
        ' code but if it works then ....)
        '
        strRTF = strRTF & "\highlight1 "
        '
        ' Finally the actual text and closing RTF brackets
        '
        strRTF = strRTF & Mid(rtb1.Text, 1, intEnd)
        strRTF = strRTF & "}}"
        '
        ' Set the RTF of the selected characters to our
        ' codes
        '
        rtb1.SelRTF = strRTF
    Else
        '
        ' We've finished
        '
        UpdateProgress = True
        intEnd = 0
    End If
    End Function
    Was it, perhaps some of your code I stumbled upon. The 'highlight' thing has had me confused for a long time !!

  18. #98
    New Member
    Join Date
    May 2008
    Posts
    1

    Re: Insert Pictures

    Thanks so much for posting these helpful RTB functions. I would like your permission to use modRTFpic.bas in a commercial application. How would you like me to credit you in the comments?

  19. #99
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Insert Pictures

    Quote Originally Posted by brianbird
    Thanks so much for posting these helpful RTB functions. I would like your permission to use modRTFpic.bas in a commercial application. How would you like me to credit you in the comments?
    This was posted in 2007, so he might not still be active, plus since he posted it here he is giving everyone permission to use it, its open.

    So give him credits if you want but its not required - at least i dont think so

  20. #100
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: RichTextBox Tricks and Tips

    I have a unique question that may compliment this thread.

    I need to highlight a line in a richtextbox only if "line starts with" mystring...

    The code needs to fire as user is typing...

    I store my search strings and unique highlight colors thus:
    Code:
        Dim searchword() As String = {"fox", "dog", "cat", "horse"}
        Dim ItemBkColor() As Color = {Color.Yellow, Color.LightYellow, Color.PaleVioletRed, Color.LightSeaGreen}
    Please can you show me how to code the richtextbox events to catch this scenario ?

    Thanks

  21. #101

  22. #102
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    327

    Re: RichTextBox Tricks and Tips

    hi moeur i am using your modRTFpic.bas in my server/client to handle smilies.it is working fine in the send part but while receiving i get a code such as
    Code:
    {\pict\wmetafile8\picw503\pich503\picwgoal285\pichgoal285 
    010009000003fe0200000000dd02000000000400000003010800050000000b0200000000050000
    000c0213001300030000001e00dd02000040092000cc0000000000130013000000000028000000
    130000001300000001000800000000007c01000000000000000000000000000000000000217b9c
    00297b9c001842a5002142a500a5a5a500ada5a500a5ada5002142ad00a5a5ad002952b500298c
    b5004a94b5005294b5003963bd002994bd00319cbd00639cbd0063a5bd006ba5bd00bdbdbd00bd
    c6bd00c6c6bd002994c60063adc6006badc600bdc6c600c6c6c6009cbdce00cecece00d6cece00
    21a5d60029a5d60029add6006bb5d60094bdd6009cbdd6009cc6d60029a5de0021adde0029adde
    009ccede00a5cede0031a5e70029ade70021b5e70031b5e70031bde7006bbde70039c6e700c6de
    e700cedee70021b5ef0029b5ef0029bdef0031bdef0029c6ef0052c6ef0073ceef007bceef00ad
    d6ef00c6d6ef00addeef00cee7ef0018b5f70021b5f70021bdf70031c6f70052c6f70073c6f700
    39cef70073cef70031d6f70039d6f7007bd6f700addef7007be7f700cee7f70031ceff0042ceff
    0031d6ff0039d6ff0042d6ff0039deff0042deff00addeff0042e7ff004ae7ff00ade7ff00b5e7
    ff004aefff0052efff00b5efff00ceefff00d6efff004af7ff0052f7ff005af7ff00d6f7ff00de
    f7ff00f7f7ff005affff00d6ffff00f7ffff00ffffff00ffffff00ffffff00ffffff00ffffff00
    ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
    00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
    ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
    ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
    ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
    00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
    ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
    ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
    ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
    00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
    ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
    ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
    ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
    00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
    ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
    ffff00ffffff006767676667663e29180b12243266666767676700676767673e211f2533342b1e
    16103167676767006767663b203503030303030303200a236667670067673d2d42031367671c67
    671303400f1b676300675c2d5003671367671c6767136703400e3c67006644480304671367671c
    6667136708032711630061370304041413131c1c1c1315130404030e32004a5003670467146767
    1c676613670467031f22003953036705671367671c676713670467032b12003859036704661367
    671c66671367046703330c0049560d030303030303030303030303030934180057532a5f5f5a5a
    605a5a59555252484d0d20280062505a606060605a5f5a5a5a5556534d421f3e00664956605201
    0101115f110101013050362166006761485f016060605e5a5a5a55560150204c67006767585360
    60605f605f5a595655532e3b6767006767665848595f605f5a595a55512e3d6766670067676766
    61494e56565a594845395c6767676600666767676763614a49383a4a5d63676766676700040000
    002701ffff030000000000
    instead of the smileys ..where am i going wrong ?:s

  23. #103

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    I would have to see the relevant sections of your code to be of any help.

  24. #104
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    327

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    I would have to see the relevant sections of your code to be of any help.
    here , i have uploaded a rough project . i can send smileys from my server to the client and out put them on a textbox but when i send smileys and a message together i am not able to output smileys
    Last edited by pannam; Jul 30th, 2008 at 11:51 AM.

  25. #105

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    Sorry,

    I don't see where you are using my code.
    Perhaps you should talk to the hand.

  26. #106
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    327

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by moeur
    Sorry,

    I don't see where you are using my code.
    Perhaps you should talk to the hand.
    i got it solved (a silly mistake) .A big thanks to you, as this post got me started and i learned a lot from this post and your project as well ..all in all i got so confused i uploaded a different project .sorry .
    lastly ,
    great work

  27. #107
    New Member
    Join Date
    Aug 2008
    Posts
    1

    Re: RichTextBox Tricks and Tips

    Is there anyway to change the color of the link?

  28. #108

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: RichTextBox Tricks and Tips

    Not that I know of.

  29. #109
    Lively Member
    Join Date
    Jun 2006
    Posts
    89

    Re: RichTextBox Tricks and Tips

    moeur, thanks for all your work and these valuable tips.

    I am trying to create a module which will actually create a RTF file (document).
    To do this, I am writing RTF control words and codes out to the file.
    I am able to do it for plain text, and colored text, and pictures/images,
    and lines and rectangles.

    But for ROTATED text (text which is NOT horizontal, but lies at an angle on the page), I am bumping into a brick wall.

    I have been able to "sort of" solve this by creating a temporary picture object with the rotated text in it, then writing that picture out to the RTF.
    This works, but it is somewhat clumsy... and my determination of the picture dimensions, based on the angle of text rotation is really clumsy.

    So I am looking for an alternative.

    I am looking at the code details of an RTF file which has rotated text in it.
    It uses a "shape", and then inserts a long string of hex data after all the appropriate codes. And this does it just fine.

    So, to my question,
    do you have any further info on the format/content of the hex string which I might be able to use to employ this solution, rather than my picture box ?

    I enclose a direct copy/paste of the rtf file which contains the "shape" code and which seems to work.

    Code:
    {\shp{\*\shpinst\shpleft0\shptop0\shpright32000\shpbottom32000
    \shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1025
    {\sp{\sn shapeType}{\sv 75}}
    {\sp{\sn fFlipH}{\sv 0}}
    {\sp{\sn fFlipV}{\sv 0}}
    {\sp{\sn pib}{\sv 
    {\pict\wmetafile8
    0100090000038200000002001C00000000000400000003010800050000000B0200000000050000000C02007D007D1C000000FB023DFF00007A0D7A0D90010000000000100000417269616C00A775440F0AA2709F740730CA120010DAA475C060A775610F66A7040000002D010000050000000902FF8000001A000000210527002E205072696E7420707265766965772069732074686520626573742C20616E676C6520333435B00050195019050000000902010000001C000000FB021000070000000000BC02000000000102022253797374656D0000610F66A700000A0022008A0100000000FFFFFFFFBCCA1200040000002D01010004000000F0010000030000000000
    }}}
    }
    }
    The hex in red is the actual string displayed....
    "Print Preview is the best, angle 345 [code for 'degrees']",
    and the color is sort of "orange".

    I need to know what all the code leading up to, and following that text is.

    I have searched high and low, but just can't seem to find anything.

    Can you help me, please.

    Thanks

  30. #110
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: RichTextBox Tricks and Tips

    Search for Windows Metafile. Afaik the hex presentation is just a regular data of a WMF file.

  31. #111
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: RichTextBox Tricks and Tips

    The file MISUIUtilities.ocx is still missing from your two zip files posted in #83 and #88.

  32. #112
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: RichTextBox Tricks and Tips

    Is there a way to prevent users from resizing the images when they are inserted into a RTB?

  33. #113
    New Member
    Join Date
    Oct 2005
    Posts
    13

    Re: RichTextBox Tricks and Tips

    I don't get the following code perform correctly:

    vb Code:
    1. Private Sub text2ADDText(xText As RichTextBox, fontN As String, fontS As Integer, fontI As Boolean, fontU As Boolean, fontB As Boolean, txt As String)
    2.     Dim text2Len As Long
    3.        
    4.     text2Len = Len(xText.Text)
    5.     xText.Text = xText.Text & vbCr & vbLf & txt
    6.     xText.SelStart = text2Len + 2
    7.     xText.SelLength = Len(txt)
    8.     xText.SelBold = fontB
    9.     xText.SelUnderline = fontU
    10.     xText.SelFontName = fontN
    11.     xText.SelFontSize = fontS
    12.    
    13. End Sub

    It only produces the desired result in the last line added to the control invoking the sub.

    Could you help me ...


    El quijoteMx

  34. #114
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by quijotemx
    I don't get the following code perform correctly:
    Is this any better?
    Code:
    Private Sub AppendText(RTB As RichTextBox, _
                    fontN As String, _
                    fontS As Integer, _
                    fontI As Boolean, _
                    fontU As Boolean, _
                    fontB As Boolean, _
                    NewText As String, _
                    Optional TextColor As Long = vbBlack)
    
        With RTB
            .SelStart = Len(.Text)
            .SelColor = TextColor
            .SelBold = fontB
            .SelItalic = fontI
            .SelUnderline = fontU
            .SelFontName = fontN
            .SelFontSize = fontS
            .SelText = vbCrLf & NewText
        End With
    
    End Sub

  35. #115
    New Member
    Join Date
    Feb 2009
    Posts
    1

    Re: Insert Tables

    moeur:
    I downloaded your program to make tables in RichTextBox.
    I am using It in a program I'm developing; when I run my program It writes the new table, but It repeats the table that was in the RichTextBox. How do I delete the first table and show only the new table?

    This is:



    1 UNO 2 12 5 5
    3 TRES 2 7 4 5
    5 CINCO 2 12 5 5
    6 SEIS 2 12 5 5
    7 SIETE 2 12 5 5
    25 25 2 12 5 5
    40 40 2 4 4 5
    41 41 2 12 5 5
    42 42 2 12 5 5
    43 43 2 12 5 5
    44 CUATROCUAT 2 10 4 5
    45 CUATROCINC 2 12 5 5
    46 CUATROSEIS 2 4 4 5
    47 CUATROSIET 2 12 5 5
    48 CUATROOCHO 2 12 5 5
    49 CUATRONUEV 2 7 4 5
    50 CINCUENTA 2 8 4 5
    51 CINCOUNO 2 11 5 5
    52 CINCODOS 2 10 4 5
    60 60 2 12 5 5
    61 61 2 5 5 5



    1 UNO 2 12 5 5
    3 TRES 2 7 4 5
    5 CINCO 2 12 5 5
    6 SEIS 2 12 5 5
    7 SIETE 2 12 5 5
    40 40 2 4 4 5
    41 41 2 12 5 5
    42 42 2 12 5 5
    43 43 2 12 5 5
    44 CUATROCUAT 2 10 4 5
    45 CUATROCINC 2 12 5 5
    46 CUATROSEIS 2 4 4 5
    47 CUATROSIET 2 12 5 5
    48 CUATROOCHO 2 12 5 5
    49 CUATRONUEV 2 7 4 5
    50 CINCUENTA 2 8 4 5
    51 CINCOUNO 2 11 5 5
    52 CINCODOS 2 10 4 5
    60 60 2 12 5 5
    61 61 2 5 5 5


    Thanks You.
    fsossaco
    {Email removed}

  36. #116
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Re: RichTextBox Tricks and Tips

    Does Anybody Know How To Make Bold Writing In A Rich Textbox?
    I Have Tried Lots Of Ways But Just Cannot Seem To Find One.

    Cheers Daniel

  37. #117
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    Re: RichTextBox Tricks and Tips

    Welcome to VBForums

    I'm afraid you are in the wrong forum - this one is for VB6 and earlier, and according to your profile you are using VB2008, which is VB.Net

    You may be able to find a thread like this in our CodeBank - Visual Basic .NET forum which contains the answer. If not, try asking in our VB.Net forum.

  38. #118
    New Member
    Join Date
    Jun 2009
    Posts
    2

    Re: RichTextBox Tricks and Tips

    Thanks for the great RTB tips.

    I'm trying to get the spell check to work, all is OK except for right-click to display menu of suggestions. I think this is because all my RTBs are within various pages of SSTab controls on my forms, so the RTB's parent is not the form itself.

    I tried some basic changes to clsSpellCheck, such as hard-coding frmxxxx.hwnd rather than mRTB.Parent.hwnd, but with no success.

    Am I wasting my time trying to do this with RTBs contained within SSTabs rather than directly within the form?
    Last edited by ycdbsoya; Jun 26th, 2009 at 09:21 PM.

  39. #119
    New Member
    Join Date
    Jun 2007
    Location
    Hamburg, Germany
    Posts
    7

    Re: Auto Detect and respond to URLs

    The code is really neat and it works.
    Unfortunately it disables the RTB's Change and SelChange events, and I need at least the Change Event to enable the Save button in my Toolbar and to ask for to save changes on exit.
    Any solutions?

  40. #120
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: RichTextBox Tricks and Tips

    KeyPress and tracking text length between saves/status checks should work for you. The only case it won't work is when someone pastes and cuts texts of exact length by using mouse only. I'd say that is pretty rare. If you use a custom context menu or disable it then this too becomes a non-issue.
    Last edited by Merri; Jul 7th, 2009 at 08:47 AM.

Page 3 of 4 FirstFirst 1234 LastLast

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