By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

ucase

lee123
100+
P: 556
how do you change a certsain field to all caps i have tried this statement but didn't work:

Expand|Select|Wrap|Line Numbers
  1. txtcompanyname.seltext = ucase(txtcompanyname.Seltext)
is this correct or what else do i need to add

ps. i put this in the form load event does that matter?

lee123
Jan 13 '08 #1
Share this Question
Share on Google+
6 Replies


Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1. txtcompanyname.seltext = ucase(txtcompanyname.Seltext)
This statement should do the trick.

But note that as with any other statement, it only does its job once, when you execute it. So if it is done in the Form_Load event, it will happen once while the form is being loaded. If there's nothing in the textbox at that time, it won't have any effect.

Hm... on further consideration, I doubt this will ever have any effect. Because you are referring to SelText, which is presumably the selected part of the text. How could you have selected any of the text before the form is even displayed?
Jan 13 '08 #2

lee123
100+
P: 556
hey killer42,

so how do i make it so when i enter in the name it comes out in caps if the caps is not on.

by the way i got this code out of a book as an example

lee123
Jan 13 '08 #3

Expert 5K+
P: 8,434
Well, you put this code where you want it to execute. For instance, if you want it to happen every time the user presses a key, you'd put it in the textbox's KeyDown or KeyPress event procedure. However, if you're not careful this can mess up the user by changing their cursor position within the text while they're typing - not nice. Possibly a better point to do it is when the focus leaves the textbox (LostFocus event).

Note that I'm referring to events in VB6. The names and so on may vary slightly in your version. Judging by the use of .SelText I'm guessing this is a later version than mine.

Also, keep in mind whether you want to adjust all of the textbox contents, or just the part which is currently selected. My guess is that the .SelText property refers to the latter. For the entire contents you'd probably want to use either .Text or .Value property.


P.S. It would really help if you fill us in on some background. Such as what version of VB you're using, what you mean by a "field" and so on. I've been assuming you're referring to a textbox control.
Jan 14 '08 #4

lee123
100+
P: 556
Ok im using vb6 and i just wanted to (cap) a textbox named (txtcompanyname)
the (seltext) i got from a book named mastering visual basic 6.0 i guess i was just looking what i could do for this textbox to have enter all caps in this box only.

lee123
Jan 14 '08 #5

lee123
100+
P: 556
oops wrong button any thanks killer42 it works now.

lee123
Jan 14 '08 #6

Expert 5K+
P: 8,434
oops wrong button any thanks killer42 it works now.
Glad to hear you've sorted it out. :)

Oh, and I made a big goof in my earlier post. SelText is a property of textboxes in VB6. I had just forgotten it.
Jan 14 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.