Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The difference between listbox and label?

28 views
Skip to first unread message

The Finder

unread,
Apr 2, 2013, 5:48:00 PM4/2/13
to
Can someone tell me what is going on?
I have a listbox that loads text into itself at startup
And after user double clicks the line chosen it brings up another form with a label I call magnifier to show that line in the same font but two sizes bigger, the font chosen for both the listbox and label is Time new Roman.

Here’s the anomaly I’m trying to figure out. In the list box if there is a “&” sign it shows up as a weird Underscore in the label form. Can someone tell me why this is happing and is there a way to get the label to show it for what it is a “&” sign?
Thank you in advance for your help.

Karl E. Peterson

unread,
Apr 2, 2013, 5:57:12 PM4/2/13
to
The Finder has brought this to us :
> Here's the anomaly I'm trying to figure out. In the list box if there is a
> "&" sign it shows up as a weird Underscore in the label form. Can someone
> tell me why this is happing and is there a way to get the label to show it
> for what it is a "&" sign? Thank you in advance for your help.

It's creating an "accelerator key" for you. With a label control,
focus will shift to the next control in the taborder when the user
presses Alt and the key that follows the &.

To actually display an & in a label, just double them up...

Label1.Caption = Replace$(NewCaption, "&", "&&")

--
.NET: It's About Trust!
http://vfred.mvps.org


The Finder

unread,
Apr 2, 2013, 6:24:00 PM4/2/13
to
On Tuesday, April 2, 2013 4:57:12 PM UTC-5, Karl E. Peterson wrote:
> To actually display an & in a label, just double them up... Label1.Caption = Replace$(NewCaption, "&", "&&") -- .NET: It's About Trust! http://vfred.mvps.org
Hi Karl, thanks for your reply.
If this is the only way to get it to show up as an "&" sign "&&" then I guess it's going to have to stay with the underscore thingy.
this list box is showing a contacts list, name, phone# and address's
and one customer told me that they used the "&" sign in the list box and when they double click it, the magnifier they see the underscore. So unless they want to type in two "&&" and I don't think they will. It’s going to stay.
Again thanks for your reply and teachings.

Karl E. Peterson

unread,
Apr 2, 2013, 7:58:43 PM4/2/13
to
on 4/2/2013, The Finder supposed :
> On Tuesday, April 2, 2013 4:57:12 PM UTC-5, Karl E. Peterson wrote:
>> To actually display an & in a label, just double them up... Label1.Caption =
>> Replace$(NewCaption, "&", "&&")
>
> Hi Karl, thanks for your reply.
> If this is the only way to get it to show up as an "&" sign "&&" then I guess
> it's going to have to stay with the underscore thingy. this list box is
> showing a contacts list, name, phone# and address's and one customer told me
> that they used the "&" sign in the list box and when they double click it,
> the magnifier they see the underscore. So unless they want to type in two
> "&&" and I don't think they will. It’s going to stay. Again thanks for your
> reply and teachings.

Huh? You're not displaying the data as the user wants to see it, so
you choose to blame - the user?!?

Maybe I misunderstand, but I thought you controlled how the label was
captioned? Hard to see how something this simple generates the "F'it!"
response. <shrug>

The Finder

unread,
Apr 2, 2013, 8:10:09 PM4/2/13
to
On Tuesday, April 2, 2013 6:58:43 PM UTC-5, Karl E. Peterson wrote:
>You're not displaying the data as the user wants to see it, so you choose to blame - the user?!? Maybe I misunderstand, but I thought you controlled how the label was captioned? Hard to see how something this simple generates the "F'it!" response. <shrug> -- .NET: It's About Trust! http://vfred.mvps.org

I’m not blaming the user, I’m just stating a fact, the user types in a name, phone# and and address, in this case she typed in for the name something like “Jim & Laura lastname” now she’s edited that to be “Jim / Laura” and she’s fine with that.
I mean it's just a contacts list, and on the main screen you don't want to have it show "Jim && Laura" any ways so as I've stated she's happy now knowing that the "/" works for her comfort.

Karl E. Peterson

unread,
Apr 2, 2013, 8:29:54 PM4/2/13
to
The Finder expressed precisely :
> On Tuesday, April 2, 2013 6:58:43 PM UTC-5, Karl E. Peterson wrote:
>> You're not displaying the data as the user wants to see it, so you choose to
>> blame - the user?!? Maybe I misunderstand, but I thought you controlled how
>> the label was captioned? Hard to see how something this simple generates the
>> "F'it!" response. <shrug>
>
> I’m not blaming the user, I’m just stating a fact, the user types in a name,
> phone# and and address, in this case she typed in for the name something like
> “Jim & Laura lastname” now she’s edited that to be “Jim / Laura” and she’s
> fine with that. I mean it's just a contacts list, and on the main screen you
> don't want to have it show "Jim && Laura" any ways so as I've stated she's
> happy now knowing that the "/" works for her comfort.

You seem to be missing my point. *YOU* are the one assigning a value
to the label's caption, right? Your code is, at any rate. Now, if I
got that straight, then why can't/won't you also check for that one
anomolous situation, and correct it when found? I've had to do this
exact thing with that very same sort of app before.

Maybe I misunderstand the mechanism that's triggering the display
update? If not your code, what?

Henning

unread,
Apr 2, 2013, 8:33:10 PM4/2/13
to

"The Finder" <ku...@birthdayfinder.org> skrev i meddelandet
news:c0d758ff-9c82-49fb...@googlegroups.com...
And it will not if you use Karls advice, why should it?

/Henning



Eduardo

unread,
Apr 2, 2013, 9:00:44 PM4/2/13
to

"The Finder" <ku...@birthdayfinder.org> escribi� en el mensaje
news:35e6688d-9441-489a-91bb-

>> Label1.Caption = Replace$(NewCaption, "&", "&&")

> If this is the only way to get it to show up as an "&" sign "&&" then I
> guess it's going to have to stay with the underscore thingy.
> this list box is showing a contacts list, name, phone# and address's
> and one customer told me that they used the "&" sign in the list box and
> when they double click it, the magnifier they see the
> underscore. So unless they want to type in two "&&" and I don't think they
> will. It�s going to stay.
> Again thanks for your reply and teachings.

The 'Replace$' is a VB6 function, not something to tell you that the user
must manually replace the text.

Somewhere in your code you must have something like:

Private sub List1_Click()
Label1.Caption = List1.List(List1.ListIndex)
End Sub

just change that to

Private sub List1_Click()
Label1.Caption = Replace$ (List1.List(List1.ListIndex), "&", "&&")
End Sub



Phil Hunt

unread,
Apr 2, 2013, 9:09:29 PM4/2/13
to
Try setting the lable's UseMnemonic property to False. See if it helps.


Tony Toews

unread,
Apr 2, 2013, 9:58:10 PM4/2/13
to
On Tue, 2 Apr 2013 14:48:00 -0700 (PDT), The Finder
<ku...@birthdayfinder.org> wrote:

>And after user double clicks the line chosen it brings up another form with a label I call magnifier to show that line in the same font but two sizes bigger, the font chosen for both the listbox and label is Time new Roman.
>
>Here�s the anomaly I�m trying to figure out. In the list box if there is a �&� sign it shows up as a weird Underscore in the label form. Can someone tell me why this is happing and is there a way to get the label to show it for what it is a �&� sign?

Why not use a text box control instead of a label control? The issue
with the & shouldn't exist then. (Although I haven't tested it.)

Tny

Phil A

unread,
Apr 2, 2013, 10:01:52 PM4/2/13
to
just set UseMnemonic property to False. User an type anything, and no code
is needed.


The Finder

unread,
Apr 3, 2013, 12:36:00 AM4/3/13
to
On Tuesday, April 2, 2013 6:58:43 PM UTC-5, Karl E. Peterson wrote: >You're not displaying the data as the user wants to see it, so you choose >to blame - the user?!? Maybe I misunderstand, but I thought you controlled >how the label was captioned? Hard to see how something this simple >generates the "F'it!" response. <shrug> -- .NET: It's About Trust! >http://vfred.mvps.org
_______________________________________________________________________________
Ok, maybe I do not understand something. I do understand that it would be nice to have it show on the magnifier exactly as the user types it into the listbox, but in this case I don’t know what the answer is to get the label to show it as a single “&” sign if that is the way a label displays this type of character. What is the solution to having a label display this as written into a list box if written with a single “&”?
If youre willing to share that. Thank you.

The Finder

unread,
Apr 3, 2013, 12:45:08 AM4/3/13
to
On Tuesday, April 2, 2013 9:01:52 PM UTC-5, Phil A wrote:
> just set UseMnemonic property to False. User an type anything, and no code is needed.
--------------------------------------------------------------------------------
:) Thank you Phil, this worked,
I still want to say thank you to all that assisted in fixing this. Karl, Henning, Eduardo, Phil. Thank you all, I've learned something that I will take with me.

Mike Williams

unread,
Apr 3, 2013, 3:27:49 AM4/3/13
to
"The Finder" <ku...@birthdayfinder.org> wrote in message
news:00afe5a1-511c-4fd6...@googlegroups.com...
It's not what you've learnt that is important here, but rather what you have
NOT learnt! Personally I would advise you to go back and read the initial
replies in this thread and actually try them out and, if necessary, read
them again and try them out again until you have learnt BOTH methods that
have been explained to you, and until you /fully understand/ BOTH of them.

Mike



The Finder

unread,
Apr 3, 2013, 9:13:57 AM4/3/13
to
On Tuesday, April 2, 2013 8:00:44 PM UTC-5, Eduardo wrote:
>The 'Replace$' is a VB6 function, not something to tell you that the user must manually replace the text. Somewhere in your code you must have something like: Private sub List1_Click() Label1.Caption = List1.List(List1.ListIndex) End Sub just change that to Private sub List1_Click() Label1.Caption = Replace$ (List1.List(List1.ListIndex), "&", "&&") End Sub
--------------------------------------------------------------------------------

Thanks Eduardo, it's really a nice thing to learn something new in a field that one is very interested in, I didn't know about the "Replace$" function and I've played with that too the only difference is I changed the ending to look like
List1_Click() Label1.Caption = Replace$ (List1.List(List1.ListIndex), "&", "&"
so again it nice to not only "just do as ones answer is," but to learn. Thank you. But since I can’t predict what other characters one might try using in this program I will in this case use the
“UseMnemonic = False” since that covers any and all characters, but I still appreciate the new knowledge you’ve bestowed upon me. Thank you.

Deanna Earley

unread,
Apr 3, 2013, 9:24:06 AM4/3/13
to
On 03/04/2013 14:13, The Finder wrote:
> On Tuesday, April 2, 2013 8:00:44 PM UTC-5, Eduardo wrote:
>> The 'Replace$' is a VB6 function, not something to tell you that
>> the user must manually replace the text. Somewhere in your code you
>> must have something like:
>> Private sub List1_Click()
>> Label1.Caption = List1.List(List1.ListIndex)
>> End Sub
>> just change that to
>> Private sub List1_Click()
>> Label1.Caption = Replace$ (List1.List(List1.ListIndex), "&", "&&")
>> End Sub
> --------------------------------------------------------------------------------
>
> Thanks Eduardo, it's really a nice thing to learn something new in a
> field that one is very interested in, I didn't know about the
> "Replace$" function and I've played with that too the only difference
> is I changed the ending to look like List1_Click() Label1.Caption =
> Replace$ (List1.List(List1.ListIndex), "&", "&"

That does nothing at all, it just leaves the & characters unescaped and
you'll be in exactly the same situation you started in.
You need to replace single & characters with two of them in the string
for each & to appear.

> so again it nice to not only "just do as ones answer is," but to
> learn

But learning correctly helps :)

> But since I can’t predict what other characters one might try using
> in this program I will in this case use the “UseMnemonic = False”
> since that covers any and all characters.

No others need escaping in this case.
Just make sure you double up each &, OR set UseMnemonic, never both
otherwise it'll just show two in the label.

--
Deanna Earley (dee.e...@icode.co.uk)
iCatcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)

Eduardo

unread,
Apr 3, 2013, 9:43:10 AM4/3/13
to

"The Finder" <ku...@birthdayfinder.org> escribió en el mensaje
news:eb813aa2-ec73-4c18...@googlegroups.com...
> Label1.Caption = Replace$ (List1.List(List1.ListIndex), "&", "&")

As Deanna already told you, that code does nothing.

You are replacing "&" with another "&"

Here you can study the function:
http://www.chennaiiq.com/developers/reference/visual_basic/functions/replace.asp



The Finder

unread,
Apr 3, 2013, 9:49:20 AM4/3/13
to
On Wednesday, April 3, 2013 8:24:06 AM UTC-5, Deanna Earley wrote:
>That does nothing at all, it just leaves the & characters unescaped and you'll be in exactly the same situation you started in. You need to replace single & characters with two of them in the string for each & to appear. > so again it nice to not only "just do as ones answer is," but to > learn But learning correctly helps :) >
--------------------------------------------------------------------------------
Hi Deanna, My bad,
after I saw your msg. I went back to the drawing board and saw my error, I forgot to put back the “UseMnemonic = true" in my tests and that is why it was showing 2 "&&" but your right. knowledge gained. Thank you.

The Finder

unread,
Apr 3, 2013, 10:04:04 AM4/3/13
to
On Wednesday, April 3, 2013 8:43:10 AM UTC-5, Eduardo wrote:
> As Deanna already told you, that code does nothing. You are replacing "&" with another "&" Here you can study the function: http://www.chennaiiq.com/developers/reference/visual_basic/functions/replace.asp
--------------------------------------------------------------------------------
Hi Eduardo, your right, I found my error, Thanks for the link and your patience.

ralph

unread,
Apr 3, 2013, 10:15:04 AM4/3/13
to
On Wed, 3 Apr 2013 06:13:57 -0700 (PDT), The Finder
<ku...@birthdayfinder.org> wrote:

A small warning from Murphy's Law.

Whenever you start using Replace-routines to escape special
characters, you have to be mindful to only run the routine 'once' on a
given string. (or add a test to the routine)

Another common conversion, often managed with Replace, is found when
using database elements with a single tick in SQL statements - eg.
"O'Reily".

-ralph
<g>
Message has been deleted

The Finder

unread,
Apr 3, 2013, 10:28:12 AM4/3/13
to
On Wednesday, April 3, 2013 9:15:04 AM UTC-5, ralph wrote:
> A small warning from Murphy's Law. Whenever you start using Replace-routines to escape special characters, you have to be mindful to only run the routine 'once' on a given string. (or add a test to the routine) Another common conversion, often managed with Replace, is found when using database elements with a single tick in SQL statements - eg. "O'Reily". -ralph <g>

--------------------------------------------------------------------------------
Hey ralph, I've got the classic VB6 now : )
Thanks for this Murphy's Law comment. Good stuff to know and I can see how this "Replace" function would be handy for finding the single tic O'Donnell type of situations. You too are always a good source of knowledge, in-depth as well. Thank you.

Karl E. Peterson

unread,
Apr 3, 2013, 1:23:31 PM4/3/13
to
The Finder used his keyboard to write :
I did. In my very first response. Phil Hunt then offered a second
method that I'd forgotten about. (It came about after I learned my
method.)

The Finder

unread,
Apr 3, 2013, 1:58:24 PM4/3/13
to
On Wednesday, April 3, 2013 12:23:31 PM UTC-5, Karl E. Peterson wrote:
> I did. In my very first response. Phil Hunt then offered a second method that I'd forgotten about. (It came about after I learned my method.) -- .NET: It's About Trust! http://vfred.mvps.org
---------------------------------------------------------------------------------
Hi Karl, Your right, you did, I just didn't understand it at that time. thank you.

CoderX

unread,
Apr 4, 2013, 12:03:56 AM4/4/13
to

"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:kjfr77$fn7$1...@dont-email.me...
>
> Huh? You're not displaying the data as the user wants to see it, so you
> choose to blame - the user?!?
>
> Maybe I misunderstand, but I thought you controlled how the label was
> captioned? Hard to see how something this simple generates the "F'it!"
> response. <shrug>

Karl, you really need to see this guy's wares first. That'll explain
everything you need to know.

https://birthdayfinder.org/bdf/whatisdateminder.html

But...I warn you, once you see these things, you can never un-see them.
You've been warned. <g>


CoderX

unread,
Apr 4, 2013, 12:06:08 AM4/4/13
to

"Mike Williams" <Mi...@WhiskyAndCoke.com> wrote in message
news:kjglh0$fil$1...@dont-email.me...
>
> It's not what you've learnt that is important here, but rather what you
> have NOT learnt! Personally I would advise you to go back and read the
> initial replies in this thread and actually try them out and, if
> necessary, read them again and try them out again until you have learnt
> BOTH methods that have been explained to you, and until you /fully
> understand/ BOTH of them.

He has to spend at least one paragraph kissing ass, otherwise he won't get
the attention he wants. It's like Munchausen syndrome, in reverse. <g>


.NET Sales Support

unread,
Apr 4, 2013, 1:22:24 AM4/4/13
to
"CoderX" <co...@x.com> wrote in message <news:kjitv2$d0q$1...@dont-email.me>...
What's the problem? It's actually about time someone used Visual Basic
for DOS to write some real programs.


The Finder

unread,
Apr 4, 2013, 9:36:32 AM4/4/13
to
On Wednesday, April 3, 2013 11:03:56 PM UTC-5, Poserx wrote:
> Karl, you really need to see this guy's wares first. That'll explain everything you need to know. https://birthdayfinder.org/bdf/whatisdateminder.html But...I warn you, once you see these things, you can never un-see them. You've been warned. <g>
--------------------------------------------------------------------------------
Poser x,
Thanks for the free publicity again. I knew I could count on you. What took you so long? sucking dik again.

Karl E. Peterson

unread,
Apr 4, 2013, 6:02:22 PM4/4/13
to
CoderX submitted this idea :
> Karl, you really need to see this guy's wares first. That'll explain
> everything you need to know.

Thanks. I think.
0 new messages