VB - Enhanced StrConv(Whatever, vbProperCase)-VBForums
Results 1 to 1 of 1

Thread: VB - Enhanced StrConv(Whatever, vbProperCase)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Location
    Forest
    Posts
    545

    VB - Enhanced StrConv(Whatever, vbProperCase)

    Try this and see what you get.
    MsgBox StrConv("a!a@a#a$a%a^a&a(a{a[a;a.a_a-a+a=a'a*a|a\a/a:a?a>a<a~a""a", vbProperCase)

    Then, try this
    MsgBox fProperCase("a!a@a#a$a%a^a&a(a{a[a;a.a_a-a+a=a'a*a|a\a/a:a?a>a<a~a""a")
    Code:
    Private Function fProperCase(strData As String) As String
        strData = StrConv(strData, vbProperCase)    'Will only take care of space
        
        Dim strDelim As String
        'strDelim = "~!@#$%^&({[;_-+='""*|\/:?<>." 'Delete chars or Add additional chars
        strDelim = strDelim & fGrabChar(33, 47)
        strDelim = strDelim & fGrabChar(58, 64)
        strDelim = strDelim & fGrabChar(91, 96)
        strDelim = strDelim & fGrabChar(123, 126)
        strDelim = Replace(strDelim, ".", "", 1, , vbTextCompare) 'Get rid of period or it will interfere with file extention
        'MsgBox strDelim
        
        Dim strChar As String
        Dim intPos As Integer
        Dim strZ As String
        Dim intX As Integer
        For intX = 1 To Len(strDelim)
            strZ = Mid(strDelim, intX, 1)  'Go through each of char in strDelim
            intPos = 0
            
            Do
                'Get position of current delimiter
                intPos = InStr(intPos + 1, strData, strZ, vbTextCompare)
                strChar = Mid(strData, intPos + 1, 1)
                If intPos = 0 Then Exit Do  'Check if anymore exist
                
                'Update with a Ucase
                strData = Replace(strData, strZ & strChar, strZ & UCase(strChar), 1, , vbTextCompare)
            Loop
        Next
        fProperCase = strData
    End Function
    
    Private Function fGrabChar(intStart As Integer, intEnd As Integer) As String
        Dim intX As Integer
        For intX = intStart To intEnd
            fGrabChar = fGrabChar & Chr(intX)
        Next
    End Function
    Last edited by Hawk; Feb 28th, 2003 at 09:06 AM.
    Bird of Prey

    Mr. Bald Eagle.
    [img][/img]

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.