Inverts the case of the selected text

This is a visual basic 6.0 source code that inverts the case of the selected text. If the upper case text is selected then it will convert it into lower case text. Otherwise to upper case.

'*******************************************************
'*     MYCPLUS Sample Code - https://www.mycplus.com     *
'*                                                     *
'*   This code is made available as a service to our   *
'*      visitors and is provided strictly for the      *
'*               purpose of illustration.              *
'*                                                     *
'* Please direct all inquiries to saqib at mycplus.com *
'*******************************************************

Public Function InvertCase(ByVal Text As String) As Text
    Dim i As Integer
    Dim sBuff As String, sFinished As String

    'For every selected letter
    For i = 1 To Len(Text)
        sBuff = Mid$(Text, i, 1) '// Get letter
        Select Case Asc(sBuff)
            Case 65 To 90 '// If it is upper case
                sBuff = LCase(sBuff) '// make it lower
            Case 97 To 122 '// if it is lower case
                sBuff = UCase(sBuff) '// make it upper
        End Select
        sFinished = sFinished & sBuff '// Put that all in the buffer
    Next i
    InvertCase = sFinished
End Function
M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post