+ Reply to Thread
Results 1 to 13 of 13

Check to see if input box content is uppercase

Hybrid View

  1. #1
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Thumbs up Re: Check to see if input box content is uppercase

    hmm... try this out (see attached to run the macro and step through to see what's it's doing:

    Needed a little more code to do this...found a way to loop and repeat the query until the input is OK

    Enjoy and rate please

    Option Explicit
    
    Sub testcontrol()
    
    Dim TestInput As String
    Dim isOK As Boolean
    Dim i As Integer, passes As Integer
    
    isOK = False
    passes = 0
    Do
    
    If passes > 0 Then
    'prompt again
        MsgBox ("please only enter upper-case letters and number at next prompt")
        TestInput = InputBox("UpperCase Letters & Number only please")
    Else
        TestInput = InputBox("UpperCase Letters & Number only please")
    End If
    
    passes = passes + 1
    For i = 1 To Len(TestInput)
        isOK = checkValidity(Mid(TestInput, i, 1))
        If isOK = False Then
        'bounce
            i = Len(TestInput)
        End If
    Next i
    Loop While Not isOK
    End Sub
    
    Function checkValidity(test As String) As Boolean
    Dim i As Integer
    Dim ok As Boolean
    Dim valarray(1 To 36) As String
    
    ok = False
    valarray(1) = "A"
    valarray(2) = "B"
    valarray(3) = "C"
    valarray(4) = "D"
    valarray(5) = "E"
    valarray(6) = "F"
    valarray(7) = "G"
    valarray(8) = "H"
    valarray(9) = "I"
    valarray(10) = "J"
    valarray(11) = "K"
    valarray(12) = "L"
    valarray(13) = "M"
    valarray(14) = "N"
    valarray(15) = "O"
    valarray(16) = "P"
    valarray(17) = "S"
    valarray(18) = "T"
    valarray(19) = "W"
    valarray(20) = "X"
    valarray(21) = "Y"
    valarray(22) = "Z"
    valarray(23) = "0"
    valarray(24) = "1"
    valarray(25) = "2"
    valarray(26) = "3"
    valarray(27) = "4"
    valarray(28) = "5"
    valarray(29) = "6"
    valarray(30) = "7"
    valarray(31) = "8"
    valarray(32) = "9"
    
    For i = 1 To 36
        If test = valarray(i) Then
            ok = True
        End If
    Next i
    
    checkValidity = ok
    
    End Function
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1