Results 1 to 11 of 11

Thread: How to format a string?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Question How to format a string?

    I'm looking for a way to format a string. Is there a way to format a string that will be shown in a textbox?

    Here's what I want to do.
    Code:
    Dim strName As String
    
    strName = "Company Name:" & vbCrLf & _
                     "University of Winsconsin Stout" & vbCrLf vbCrLf & _
                     "Department:" & vbCrLf & _
                     "Development"
    
    txtbox1.text = strName
    In the above code, I want to bold the heading "Company Name:" and "Department:" and then italicize the "University of Wincosin Stout" and "Development".

    Is there a to format this at run time with code?

    ljCharlie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't think you can do this on a textBox . If RichTextBox won't do this , then DrawString will do it [GDI+].

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Thanks, Pirate!

    I just thought I give it a try. Well, it's okay.

    ljCharlie

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    By the way, Pirate, do you know a way to write the texts to a textbox or richtextbox in design time? I want to write the About and Help section of my application in design mode, but I couldn't find an easier way to do it.

    Thanks!

    ljCharlie

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What about writing it in a text file , then load it after your application is launched . I think even MS follow this convention .

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Perhaps textbox won't do it but richtextbox will retain my format such as bold, italics, tab, and things of that nature if a load the file in run time, right?

    ljCharlie

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If you wrote and formatted the text (bold , colored ...) in rtf files , then you loaded it in RTF control, sure it will pertain everything .

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    One other question. I know this can be done but I don't know how to do it. When I load the RTF file from the directory, how do I read the information in that file? For example, I have topics such as Introduction, Updating, Inserting, Deleting. When the user click on the Updating topic, how do I load just the Updating section into my richtextbox from the file and kept the rest from loading into the richtextbox? I know that I would have to format my RTF file in such a way that there is a unique charactor before the next topic section start...but I don't know how to read from the file and determine that unique charactor to start and stop loading into the textbox.

    Sorry for asking too much of you, but I really do need help.

    Many thanks for your help.

    ljCharlie

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Here's a quick domo with commented code .
    Attached Files Attached Files

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Thanks, Pirate. I'll give that look next week. I'm off for the weekend.

    ljCharlie

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    I gave your sample a try and it does pretty much what I wanted to do; however, I couldn't get each section to load individually. Every time when I want to load, let's say, Deleteing section, the Introduction section and any section that is above the Deleting section will also appear in the richtextbox. Is there a way to fix this problem? Right now the problem is that all section that is before the specify section appear in the rtf box and I only want the section that I choose to load.

    ljCharlie

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