Capitalization

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akoymakoy
    New Member
    • Oct 2006
    • 42

    #1

    Capitalization

    How do i check if the first character in a textbox is capitalized or not?
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    dim num as int

    on error resume next ' just in case the first character is a number

    num = ASC(left(text1. text, 1))
    if num >= 65 and num <= 90 then
    ' it is capitalized
    ' do something
    else
    '
    end if

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by scripto
      dim num as int

      on error resume next ' just in case the first character is a number

      num = ASC(left(text1. text, 1))
      if num >= 65 and num <= 90 then
      ' it is capitalized
      ' do something
      else
      '
      end if
      It's more fun to have more than one way to do things. :)
      So, another alternative would be...
      Code:
      Select Case Left$(Text1.Text,1)
        Case "A" to "Z"
          ' It is capitalised (Australian spelling)
        Case Else
          ' It isn't.
      End Select
      I just like the Select statement because the "TO" clause allows you to avoid complicating things with ANDs and ORs. It's just a matter of personal preference.

      Comment

      Working...