Finding A Character Within A Textbox

RockyAndNickels

Lil' Programming Dude
Local time
Today, 09:38
Joined
Jan 14, 2007
Messages
11
I need to find a character within a textbox. The common text within this textbox is a number (between 1 and 10) and up to five letters (from these letters: R, G, B, U, W). An example would look like this: 3G, 1RRR, RG.

Anyways, I need to find out what the letter(s) is/are in this textbox to do something else.
 
Place this function in a module.

Code:
Const MyLetters = "RGBUW"
Function FindLetters(strInput As String) As String

Dim x As Integer
Dim strOut As String

strOut = ""

If strInput = "" Then
     FindLetters = ""
     Exit Function
End If

For x = 1 To Len(strInput)
     If InStr(1, MyLetters, Mid(strInput, x, 1)) <> 0 Then
        strOut = strOut & Mid(strInput, x, 1)
    End If
Next

FindLetters = strOut

End Function

Example:
Code:
Dim str As String
str = FindLetters(Me!MyTextBox)

Should work - haven't tested.

Regards,
Pete
 

Users who are viewing this thread

Back
Top Bottom