I have a String containing several times a “&”. They don’t show in the Label.Value. But they do in a Msgbox String. If I add an extra “&” then “&” shows in the Label.Value but “&&” in the Msgbox. What am I missing? How do I get the same text in the Label as shown in the Msgbox.
Hello,
try && instead of &.
[quote=459697:@Christian Mézes]Hello,
try && instead of &.[/quote]
Tried this and the Label now looks OK but the String has && and is used elsewhere too causing issues.
[quote=459697:@Christian Mézes]Hello,
try && instead of &.[/quote]
Edit: Sorry, I see you already tried that.
Maybe a constant could help: Create a new constant “my_constant” and enter the text. Then do: myLabel.Text = my_constant
In Labels, I believe that &something defines an accelerator key. By setting &&, you signal that you really want an &. Since there is no accelerator key in msgbox, a single & works as you expect.
const myLabel = "&This is my & Label"
label1.text=replaceall(mylabel,"&","&&")
this way only the text of the label is affected, and “mylabel” can be used everywhere else
Thanks everyone for the amazing quick response and solution!
[quote=459702:@Dave S]
const myLabel = "&This is my & Label"
label1.text=replaceall(mylabel,"&","&&")
this way only the text of the label is affected, and “mylabel” can be used everywhere else[/quote]
label1.text=replaceall(mylabel,"&","&&") actually resulted in &&&&.
label1.text=replaceall(mylabel,"&&","&") did the job
don’t see how that would be possible…
since what I posted would have changed every “&” into “&&”, which would be required for a label
as in it would have made
- “&This is my & Label” into “&&This is my && Label”
the other way would have resulted in no changes whatsoever, since there were no “&&” to begin with
I seem to recall that & was special in nature particularly for menu Alt-Keys…
Where the letter following the the & would be used as a hot key to activate that item.
Pretty much every textual item on the UI can have an accelerator so & is special in UI controls that have “labels” like checkboxes, labels, pushbuttons etc etc