dcsimg
Results 1 to 10 of 10

Thread: VBA Invalid Qualifier on Strings

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    VBA Invalid Qualifier on Strings

    I'm working on a simple Macro for Excel, but I'm new to Visual Basic and I'm encountering some errors when working with strings. Here's an example of the error I keep running into:

    Sub test()

    Dim s1 As String
    Dim s2 As String
    s1 = "which case"
    s2 = s1.ToUpper

    End Sub

    When I try to run this, I keep getting the error "Invalid Qualifier" highlighting s1.ToUpper

    Thanks for any help!

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    Re: VBA Invalid Qualifier on Strings

    I went in through Excel and am using the Visual Basic Editor under Macros. I then added a new module in the VB Editor which is where my code is located.

  4. #4

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VBA Invalid Qualifier on Strings

    Quote Originally Posted by amzngspiderman29
    I'm working on a simple Macro for Excel, but I'm new to Visual Basic and I'm encountering some errors when working with strings. Here's an example of the error I keep running into:
    Code:
    Sub test()
    
    Dim s1 As String
    Dim s2 As String
    s1 = "which case"
    s2 = s1.ToUpper
    
    End Sub
    When I try to run this, I keep getting the error "Invalid Qualifier" highlighting s1.ToUpper

    Thanks for any help!
    The code you wrote is for VB.NET? That does not work in VB6 or VBA.
    Change it to:
    Code:
    Sub test()
       Dim s1 As String
       Dim s2 As String
    
       s1 = "which case"
       s2 = UCase(s1)
    
    End Sub
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    Baby Steps a guided tour
    IsDigits() and IsNumber() functions Wichmann-Hill Random() function >> and << functions for VB CopyFileByChunk

  6. #6
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: VBA Invalid Qualifier on Strings

    However,if you write it in a formula in a cell, you would use Upper(A1), at least through XL 2K. And if you were writing VBA (macro) code, that is what you'd need.
    Not sure if you're running XL as an application from another program.
    No idea why the same versions of office would use UCase for some apps and Upper for others.
    Tengo mas preguntas que contestas

  7. #7
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VBA Invalid Qualifier on Strings

    Quote Originally Posted by salvelinus
    However,if you write it in a formula in a cell, you would use Upper(A1), at least through XL 2K. And if you were writing VBA (macro) code, that is what you'd need.
    Not sure if you're running XL as an application from another program.
    No idea why the same versions of office would use UCase for some apps and Upper for others.
    The Sub Test() code is VB6/VBA code.
    UCase() and LCase() are 2 of basic functions in VB6/VBA, they works wherever these languages are used.

    UPPER() and LOWER() are 2 WorksheetFunctions that can be used on worksheet within formulas only.

    The reason why VB uses UCase() and LCase() but worksheetfunction uses UPPER() and LOWER() is at the creation of Excel, MS intended to make the functions compatible with Lotus 1-2-3 functions.
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    Baby Steps a guided tour
    IsDigits() and IsNumber() functions Wichmann-Hill Random() function >> and << functions for VB CopyFileByChunk

  8. #8
    New Member
    Join Date
    May 2012
    Posts
    1

    Re: VBA Invalid Qualifier on Strings

    SMonth = CBSMonth.ListIndex + 1
    SYear = CBSYear.ListIndex + 1

    when i try to run the program, they gave me the invalid qualifier msg box and highlights CBSMonth

    can any1 help me please?

  9. #9

  10. #10
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: VBA Invalid Qualifier on Strings

    Nightsiayer

    Welcome to the Forums ..

    It appears that you dilligently did a Search Forums on
    Invalid Qualifier, and thus found this thread, but, as
    Marty points out, this thread is ancient.

    So, it might be appropriate to start a new thread.
    Further, it would help if you would give a little more
    code.

    EDIT

    BTW, I'm amazed at the number of Views of this thread ... 3,348 ..
    and only 9 replies.

    Spoo
    Last edited by Spoo; May 5th, 2012 at 09:56 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width