Results 1 to 6 of 6

Thread: VBA: converting text to uppercase

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    VBA: converting text to uppercase

    I know how to convert text to uppercase in the Keypress event in VB but how do you do it using VBA?

    Thanks,

    Blake

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: VBA: converting text to uppercase

    Exactly the same way if VBA has a KeyPress event that is.... UCase$() works in VBA I think atleast.

    Cheers,

    RyanJ
    Last edited by sciguyryan; May 26th, 2005 at 12:32 PM.
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: VBA: converting text to uppercase

    VBA does have the Ucase() function, however, in VB I use the following statement in the KeyPress Event.

    Text1.Text = Ucase(Asc(Chr(Keyascii)))

    By using this statement, everytime you time a letter...it is converted to uppercase regardless if the CAPS Lock is on or not.

    Unfortunately, I can't get this to work in VBA.

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: VBA: converting text to uppercase

    Quote Originally Posted by blakemckenna
    VBA does have the Ucase() function, however, in VB I use the following statement in the KeyPress Event.

    Text1.Text = Ucase(Asc(Chr(Keyascii)))

    By using this statement, everytime you time a letter...it is converted to uppercase regardless if the CAPS Lock is on or not.

    Unfortunately, I can't get this to work in VBA.
    Well, I'm not shure if VBA has a KeyPress event - and if It does I have no idea what it would be.

    Have you tried the MSDN VBA reference?

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: VBA: converting text to uppercase

    I stand corrected.....you can use the same statement in VBA as in VB.

  6. #6
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: VBA: converting text to uppercase

    Quote Originally Posted by blakemckenna
    I stand corrected.....you can use the same statement in VBA as in VB.
    Well, thats going to save some searching time

    And unless you want to return a variant string, use this:

    VB Code:
    1. Ucase$(Asc(Chr$(Keyascii)))


    And I have one more question..... This:

    VB Code:
    1. Asc(Chr$(Keyascii))
    Is the same as just having this...

    VB Code:
    1. Keyascii

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width