Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

FlipCase - Inverting the case of all characters of the input string

Total Hit ( 2587)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 



Click here to copy the following block
' Invert the case of all characters of the input string
'
' Examples:
'  Debug.WriteLine(FlipCase("Hello World")) ' => hELLO wORLD
'  Debug.WriteLine(FlipCase("hELLO wORLD")) ' => Hello World
'  Debug.WriteLine(FlipCase("3) this is message n. 3")) ' => 3) THIS IS
' MESSAGE N. 3

Function FlipCase(ByVal input As String) As String
  Dim i As Integer
  Dim res As New System.Text.StringBuilder(input.Length)

  For i = 0 To input.Length - 1
    ' if the char is lowercase, add to the stringbuilder the char in
    ' uppercase
    If Char.IsLower(input.Chars(i)) Then
      res.Append(Char.ToUpper(input.Chars(i)))
    ElseIf Char.IsUpper(input.Chars(i)) Then
      ' if the char is uppercase, add to the stringbuilder the char in
      ' lowercase
      res.Append(Char.ToLower(input.Chars(i)))
    Else
      ' if the char is a digit or another non-letter char, add it as it is
      res.Append(input.Chars(i))
    End If
  Next
  Return res.ToString()
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.