Results 1 to 5 of 5

Thread: Vowel testing

  1. #1
    Join Date
    Jun 2007
    Posts
    40

    Unanswered: Vowel testing

    Hi I am trying to test for vowels, so that I can put "a" or "an" in a text box. To test the "like" operator in the sense that I need it, I wrote the following test code:

    Code:
    If ("a" Like [a e i o u]) Then
      MsgBox "Vowel"
    Else
      MsgBox "Consonant"
    End If
    However I get a weird error "Microsoft access can't find the field 'I' referred to in your expression". What am I doing wrong?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    LIKE is not part of standard VBA. Use instr instead. Otherwise you can reference a library but I forget which one. It is some VB language library or other.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jun 2007
    Posts
    40
    Quote Originally Posted by pootle flump
    LIKE is not part of standard VBA. Use instr instead. Otherwise you can reference a library but I forget which one. It is some VB language library or other.
    It is in my help:

    "Like Operator


    Used to compare two strings.

    Syntax

    result = string Like pattern"

    But as you say perhaps it has to be referenced.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Beg your pardon - it works fine for me too. Wonder where I got that from?

    Anyway - your string is invalid.

    Code:
    "a" LIKE "[aeiou]"
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    How about that perennial favorite, Select Case, where YourVar is whatever it is you're testing:

    Code:
    Select Case Left(YourVar, 1)
      Case "a", "e", "i", "o", "u"
        MsgBox "Vowel"
    Case Else
        MsgBox "Consonant"
    End Select
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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