Results 1 to 18 of 18

Thread: ASCII Special Characters

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    ASCII Special Characters

    I am working on a text editor which will allow my wife to write text in a language other than English (French and Spanish specifically). I want to make a series of buttons which will input one of the accented letters into the text box. How can I render a special character by simply clicking a button? I know what the codes are to create these characters in Word. Can I use the same codes?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ASCII Special Characters

    You'll have to create a resource file(s) for each language for that purpose.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by RhinoBull
    You'll have to create a resource file(s) for each language for that purpose.
    I don't think that is what I want. I understand resource files to allow me to change menu items to another language. I want to be able to output a special character to the textbox by clicking a button. Is there a way to do this?

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ASCII Special Characters

    sure thats fine. do it like this:
    button_click()
    text1.text = text1.text & chr(155)
    end sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by |2eM!x
    sure thats fine. do it like this:
    button_click()
    text1.text = text1.text & chr(155)
    end sub
    Excellent. Is there a way to get the character to show up on the button face?

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: ASCII Special Characters

    set the caption of the button to chr(155) if you want it to show up on the button

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by kfcSmitty
    set the caption of the button to chr(155) if you want it to show up on the button
    That just seems to put chr(155) on the button, not the special character.

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ASCII Special Characters

    You have to use selected font so you can actually assign some particular character from it. Also, regular textbox doesn't support multiple fonts so you might need to switch to RichTextbox.
    In any case as I said resource file is the way to go.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by RhinoBull
    You have to use selected font so you can actually assign some particular character from it. Also, regular textbox doesn't support multiple fonts so you might need to switch to RichTextbox.
    In any case as I said resource file is the way to go.
    Two questions:

    What is "selected font," and what is a resource file?

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ASCII Special Characters

    Regarding "selected font" ... that was a waky way of saying it ...
    What I meant was that you will need to set some font to a command button first and then select that "special" character for its caption.
    However, setting that special char as one of the characters in a textbox could be problematic unless button and textbox both have the same fonts.
    Using RichTextBox on the other hand will allow you to set any available font to a single character (SelFont is the property I believe) so the proper char will be displayed. Also, since fonts are usually tricky to work with you might need to (but not necessary) distribute font(s) utilized in your project.

    Here is a quote from MSDN that explains resource files in a nutshell:
    Working with Resource Files


    A resource file allows you to collect all of the version-specific text and bitmaps for an application in one place. This can include icons, screen text, and other material that may change between localized versions or between revisions or specific configurations.

    Adding Resources to a Project
    You can create a resource file using the Resource Editor add-in. The compiled resource file will have a .res file name extension. Each project can contain only one resource file.

    The actual file consists of a series of individual strings, bitmaps, or other items, each of which has a unique identifier. The identifier is either a Long or a String, depending on the type of data represented by the resource. Strings, for example, have a Long identifier, while bitmaps have a Long or String identifier. To retrieve resources in your code, learn the identifier for each resource. The function parameters referring to the resources can use the Variant data type.

    To add a new resource file to your project

    Choose Resource Editor from the Tools menu. An empty resource file will be opened in the Resource Editor window.
    Note The Resource Editor add-in must be installed. For information on installing add-ins, see "Using Wizards and Add-Ins" in "Managing Projects".

    Select the Save button on the Resource Editor toolbar to save the resource file. The file will be added to the Project Explorer under the Related Documents section.
    To add an existing resource file to your project

    Choose Add New Resource File from the Project menu. Any existing resource file in your project will be replaced.
    Caution If you make any modifications to an existing resource file it could affect other projects that use that resource file. Make sure that you save the file under a new filename.

    Note The Resource Editor add-in must be installed. For information on installing add-ins, see "Using Wizards and Add-Ins" in "Managing Projects."

    For More Information For more information on resource files, see "Using Resource Files for Localization" in "International Issues."

    Note Windows resource files are specific to 16-bit or 32-bit applications. Visual Basic will generate an error message if you try to add a 16-bit resource file to a project.

    Using Resources in Code
    Visual Basic provides three functions for retrieving data from the resource file for use in code.

    Function Description
    LoadResString Returns a text string.
    LoadResPicture Returns a Picture object, such as a bitmap, icon, or cursor.
    LoadResData Returns a Byte array. This is used for .wav files, for example.


    For More Information See the appropriate function topic.
    Last edited by RhinoBull; Jun 21st, 2005 at 04:11 PM.

  11. #11
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Re: ASCII Special Characters

    Quote Originally Posted by dmyhand
    That just seems to put chr(155) on the button, not the special character.
    I'm thinking maybe you put "chr(155)" instead of just chr(155)

    Base 2
    Fcnncu"Nqxgu"Lguug##

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by half flung pie
    I'm thinking maybe you put "chr(155)" instead of just chr(155)
    Nope. Tried that already. Is there a way to make an image show up on a button face?

  13. #13
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: ASCII Special Characters

    just type (this example is for the form load event)

    VB Code:
    1. Private Sub Form_Load()
    2. button1.caption = chr(155)
    3. end Sub

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by kfcSmitty
    just type (this example is for the form load event)

    VB Code:
    1. Private Sub Form_Load()
    2. button1.caption = chr(155)
    3. end Sub
    That is it! You guys are great. Thanks, again.

  15. #15
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ASCII Special Characters

    except it will never show the character..

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    29

    Re: ASCII Special Characters

    Quote Originally Posted by |2eM!x
    except it will never show the character..
    I am using graphics of each special character on the button faces. This seems to be the easiest way to show the characters so my wife can type them by clicking once on the button instead of alt+192 or whatever. It is coming along nicely. Thanks, dennis

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: ASCII Special Characters

    this is a great idea, i might look at doing a small program, using this to paste into other programs, to save having to search through all the fonts character map each time

    pete

  18. #18
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: ASCII Special Characters

    Quote Originally Posted by |2eM!x
    sure thats fine. do it like this:
    button_click()
    text1.text = text1.text & chr(155)
    end sub
    I would not use that code since it's very slow, besides it only allows you to add the character at the end of the text while it will move the text cursor to the beginning. Use the SelText property instead.
    VB Code:
    1. Text1.SelText = Chr$(155) 'or whatever ASCII value you want to use

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