Results 1 to 14 of 14

Thread: Displaying '&' character instead of an underscore

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    When you use an ampersand (&) symbol in a string, VB converts it to an underscore (_). How can I prevent it. I need to display an ampersand in a lable control.

    Thanks
    Thanks

    Tomexx.

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    MsgBox "this does look like an ampersand huh?  " & Chr(38) & "   yep, it is! :)"
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Jop your code doesn't show tha ampresand in a Label
    Use This
    Code:
    Label1.Caption = "this does look like an ampersand huh?  &&   yep, it is! "
    Two ampresands will show one
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    && will put an ampresand
    label1.caption = "hello&&bye"

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey you're right guys hehe dumb to only test it with a msgbox
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    Guest
    Just set the label's UseMnemonic property to False.

  7. #7
    New Member
    Join Date
    Jan 2007
    Posts
    3

    Re: Displaying '&' character instead of an underscore

    Label1.CAption = "This is a right answer &&"

  8. #8
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Displaying '&' character instead of an underscore

    Label1.Caption = "This is a 10 year old thread"
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Displaying '&' character instead of an underscore

    Quote Originally Posted by smUX View Post
    Label1.Caption = "This is a 10 year old thread"
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    New Member
    Join Date
    Jan 2007
    Posts
    3

    Re: Displaying '&' character instead of an underscore

    Really? The asker is still alive?

  11. #11
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Displaying '&' character instead of an underscore

    Quote Originally Posted by smUX View Post
    Label1.Caption = "This is a 10 year old thread"
    Perhaps you could at least punctuate the caption correctly.
    Doctor Ed

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Re: Displaying '&' character instead of an underscore

    I'm alive && well, thank you very much
    Thanks

    Tomexx.

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Displaying '&' character instead of an underscore

    Quote Originally Posted by Tomexx View Post
    I'm alive && well, thank you very much
    Well, this thread just made my day !!
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

    Re: Displaying '&' character instead of an underscore

    Quote Originally Posted by LaVolpe View Post
    Well, this thread just made my day !!
    This post actually helped me realize when using DrawText API I need to include DT_NOPREFIX flag or "&" are shown as "_" too.

    Until everyone stops coding in VB6 there is no such thing as an old thread.

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