0% found this document useful (0 votes)
18 views3 pages

Change The Case From The Given String July 7, 2014

This document describes a program to change the case of a given string in VB.NET. It includes steps to start a new project in Visual Studio, declare variables to store the input and output strings, use a for loop and ASCII values to convert characters between upper and lower case, and output the result. The coding section shows the full code to implement this, and the output section displays sample input and output when running the program.

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Change The Case From The Given String July 7, 2014

This document describes a program to change the case of a given string in VB.NET. It includes steps to start a new project in Visual Studio, declare variables to store the input and output strings, use a for loop and ASCII values to convert characters between upper and lower case, and output the result. The coding section shows the full code to implement this, and the output section displays sample input and output when running the program.

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

6.

CHANGE THE CASE FROM THE GIVEN STRING July 7, 2014




12PA01 Page 17

Aim:
~~~~
To write a program to perform changing the case of given string using vb.net.
Procedure:
~~~~~~~~~
Step1: Start the program in the Microsoft Visual Studio 2010.
Step2: File->new->project Select the project type as visual basic and select
the visual studio installed template as console application.
Step3: Choose a Name, Location and Solution name.
Step4: Declare the variables get an input string as str and assign an n variable as 0.
Step5: Using for Each loop to assign ch1=str and increment a k values as 1.
Step6: Using ASCII values to convert an upper case into lower case vice versa.
Step7: Finally the output is stored in ch1.
Step8: End of the program.

















6. CHANGE THE CASE FROM THE GIVEN STRING July 7, 2014


12PA01 Page 18

Coding:
~~~~~~
Module Module1
Sub Main()
Dim str As String
Dim ch1(20), ch2(20) As Char
Dim i, n, n1 As Integer
Console.WriteLine("Changing the case of given string")
Console.WriteLine("***************************")
Console.WriteLine("Input")
Console.WriteLine("~~~~")
Console.WriteLine("Enter the string:")
str = Console.ReadLine()
n = 0
For Each element As Char In str
ch1 = str
n = n + 1
Next
For i = 0 To n - 1
n1 = Convert.ToInt32(ch1(i))
If (n1 >= 65) And (n1 <= 92) Then
n1 = n1 + 32
ch1(i) = Convert.ToChar(n1)
ElseIf (n1 >= 97) And (n1 <= 122) Then
n1 = n1 - 32
ch1(i) = Convert.ToChar(n1)
Else
ch1(i) = ch1(i)
End If
Next
Console.WriteLine("Output")
Console.WriteLine("~~~~~")
Console.WriteLine(ch1)
Console.ReadKey()
End Sub
End Module
6. CHANGE THE CASE FROM THE GIVEN STRING July 7, 2014


12PA01 Page 19

Output:
~~~~~~
Changing the case of given string
***************************
Input
~~~~
Enter the string:
caseSTRING
Output
~~~~~~
CASEstring








Result:
*****
Thus the change the case of given string program was successfully performed.

You might also like