Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Lower Case In String

Status
Not open for further replies.

bscs1963

Programmer
Apr 7, 2009
22
US
I have a text field in a table where I need to find where the first lower case occurs in the string.

I am trying to create a bar code of the field, and there needs to be a plus sign before each lower case letter.

For instance, the value DsMldGnRR would need to have a + sign before the "s". Then it would read as D+sM+l+dG+nRR. This would actual occur before each lower case. Once I find the first case, isnerting the + sign is easy.
 
A starting point:
Code:
Public Function LowerPlus(strValue)
If IsNull(strValue) Then Exit Function
Dim i As Long, x As String, strReturn As String
For i = 1 To Len(strValue)
  x = Mid(strValue, i, 1)
  If Asc(x) >= 97 And Asc(x) <= 122 Then
    strReturn = strReturn & "+"
  End If
  strReturn = strReturn & x
Next
LowerPlus = strReturn
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
[blue]Public Function LowerPlus(strValue As String) As String
 
    With CreateObject("vbscript.regexp")
        .Pattern = "([a-z])"
        .Global = True
        LowerPlus = .Replace(strValue, "+$1")
    End With
    
End Function[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top