ucase

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    ucase

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

    Code:
    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
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by lee123
    Code:
    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?

    Comment

    • lee123
      Contributor
      • Feb 2007
      • 556

      #3
      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

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        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.

        Comment

        • lee123
          Contributor
          • Feb 2007
          • 556

          #5
          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

          Comment

          • lee123
            Contributor
            • Feb 2007
            • 556

            #6
            oops wrong button any thanks killer42 it works now.

            lee123

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by lee123
              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.

              Comment

              Working...