Program to convert the Case of a String in VB.NET

Mid() in Visual Basic.net is a string function that is used to extract a copy of                                     a character or set of characters from a string.

Syntax:
Function Mid( ByVal Str As String, ByVal Start As Integer,
Optional ByVal Length As Integer) As String

In the above syntax Str specifies the string from which the characters to be extracted from the starting position specified using Start, until the specifed Length of characters.

Program UI:

Screenshot (18).png

Program Code:

Public Class Task2

Private Sub btnoutput_Click(sender As Object, e As EventArgs) Handles btnoutput.Click
Dim len, i As Integer
Dim s, c As String
s = Textname.Text
len = s.Length
For i = 1 To len
c = Mid(s, i, 1)
If Asc(c) > 90 And Asc(c) < 123 Then
Textoutput.AppendText(UCase(c))
Else
Textoutput.AppendText(LCase(c))
End If
Next
End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
Textname.Clear()
Textoutput.Clear()
End Sub
End Class

Output:

Screenshot (17).png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s