Solved

How to enter ampersand (&) character in a TextBox without it being translated

Posted on 2008-10-13
5
522 Views
Last Modified: 2012-06-27
Hi,
When I enter (for example) "Fred & John" in a TextBox, save that text and later recall it by reloading the text box, the single ampersand (&) character is not shown but instead is interpreted as a control char.

If I enter "Fred && John" and do same as above then a single ampersand is shown on subsequent reload of that TextBox.

In the past I did something to basically inform the system to treat that character like any other but I forget now what I did. Any help?

/Michael
0
Comment
Question by:gem56
5 Comments
 
LVL 6

Accepted Solution

by:
tchamtieh earned 200 total points
ID: 22707725
Hi Michael,

I think you can just set the UseMnemonic attribute of a Label to "false" and see the magic. You might even be able to use the escape character as in \& but not so sure.

Good Luck.
0
 

Assisted Solution

by:Cosmos36
Cosmos36 earned 50 total points
ID: 22707953
How are you "saving" the text?

If you use a "string" variable, nothing should be changed when you write that variable back to the textbox. Example below:

1 Form
2 Buttons
1 Textbox

Public Class Form1
    Dim MyTextbox As String
    Private Sub BtnSaveAndClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSaveAndClear.Click

        MyTextbox = TextBox1.Text
        TextBox1.Clear()

    End Sub
    Private Sub BtnFillTextbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFillTextbox.Click

        TextBox1.Text = MyTextbox

    End Sub
End Class
0
 
LVL 6

Expert Comment

by:carlsiy
ID: 22708365
First of all, is this saved in a database? secondly is this web or windows?
0
 

Author Comment

by:gem56
ID: 22708603
Hi guys,
I must appologise for my poorly described question and limited testing, I was in a real hurry.

I actually entered the text in one dialog via a TextBox and later showed the entered text via a Label, incorrectly. Setting the UseMnemonic attribute to "false" did the trick so thank you all for responding and of course tchamtieh for the answer.

Thanks,

0
 

Expert Comment

by:Cosmos36
ID: 22718358
No problem. I am glad to help out where I can.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question