Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to Change the Caps of String in Visual Basic.Net

Author: DevASP
Download Source Code :

This article is about how you can convert a given string to alternate caps.

  • Steps you will do. 
  • Start visual studio and create a new window application.

Set the following properties of the form.

Name = frmMain

Text = Alternate Caps

Maximize = false

FormBoarderStyle = FixedSingle

  • Drop two label controls and set there following properties.


Name = lbl

Text = Enter string to convert it into alternate caps.



Name = lbfinalstring

Text = “”


  • Drop a text field and set its following properties.

Name = tbstring

Text = “”


  • Place a button control on your form and set its following properties.

Name = btconvert

Text = Convert to alternate caps.

  • Open your code window and write the following function which will do the actual work for you.

Public Function StringAlternate(ByVal stext As String, ByVal StartLowerCase As Boolean) As String


 Dim i As Int16 = 1

 Dim bAlternate As Boolean

 Dim sBuild As String


 bAlternate = StartLowerCase


 Do Until i = Len(stext) + 1


    If bAlternate = False Then


      StringAlternate = StringAlternate & UCase(Mid(stext, i, 1))

      bAlternate = True




      StringAlternate = StringAlternate & LCase(Mid(stext, i, 1))

      bAlternate = False


  End If


   i = i + 1




End Function


  • Now in the click event of the button call this function and pass the parameters as below.

 lbfinalstring.Text = StringAlternate(tbstring.Text, False)


Add Article Comment:
Name :
Email Address :
Comments :
<< How to Get the Length of the String Using Class Library

Disclaimer - Privacy
© 2002-2017