0% found this document useful (0 votes)
66 views

String Handling Function July 15, 2014

The document describes a program to perform various string handling functions in VB.NET. It outlines steps to create a Windows application project in Visual Studio, get user input, and use functions like length, concatenation, uppercase, lowercase, substring, replace, and split to manipulate strings. Code examples demonstrate implementing each function by clicking buttons that pass strings between two text boxes and display results. The goal is to successfully create a program that allows testing all the string functions.

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)
66 views

String Handling Function July 15, 2014

The document describes a program to perform various string handling functions in VB.NET. It outlines steps to create a Windows application project in Visual Studio, get user input, and use functions like length, concatenation, uppercase, lowercase, substring, replace, and split to manipulate strings. Code examples demonstrate implementing each function by clicking buttons that pass strings between two text boxes and display results. The goal is to successfully create a program that allows testing all the string functions.

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/ 6

8.

STRING HANDLING FUNCTION

July 15, 2014

Aim:
~~~~
To write a program to perform the string handling function 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 windows application.
Step3: Choose a Name, Location and Solution name.
Step4: Get an input string.
Step5: Using build function to find a string length, concatenation, split, upper case, lower
case, substring, replace, contains, remove, clear, rtrim, ltrim.
Step6: End of the program.

12PA01

Page 23

8. STRING HANDLING FUNCTION

July 15, 2014

Coding:
~~~~~
Public Class Form1
Private Sub comparecmd_Click (ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles comparecmd.Click
Dim str As String
str = InputBox("Enter the string:")
TextBox2.Text = StrComp(TextBox1.Text, str)
End Sub
Private Sub clearcmd_Click (ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles clearcmd.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub exitscmd_Click (ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles exitscmd.Click
End
End Sub
Private Sub copycmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles copycmd.Click
TextBox2 .Text =String .Copy (TextBox1 .Text)
End Sub
Private Sub ltrimcmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles ltrimcmd.Click
TextBox2.Text = LTrim (TextBox1.Text)
End Sub
Private Sub lengthcmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles lengthcmd.Click
TextBox2.Text = Len(TextBox1.Text)
End Sub
12PA01

Page 24

8. STRING HANDLING FUNCTION

July 15, 2014

Private Sub replacecmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles replacecmd.Click
Dim s, n As String
s = InputBox("Enter the string replaced:")
n = InputBox("Enter the string replace:")
TextBox2.Text = Replace(TextBox1.Text, s, n)
End Sub
Private Sub uppercmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles uppercmd.Click
TextBox2.Text = UCase(TextBox1.Text)
End Sub
Private Sub lowercmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles lowercmd.Click
TextBox2.Text = LCase(TextBox1.Text)
End Sub
Private Sub middlecmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles middlecmd.Click
Dim s, n As String
s = InputBox("Enter the middle start string:")
n = InputBox("Enter the middle end string:")
TextBox2.Text = Mid(TextBox1.Text, s, n)
End Sub
Private Sub rtrimcmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles rtrimcmd.Click
TextBox2.Text = RTrim(TextBox1.Text)
End Sub
Private Sub substringcmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles substringcmd.Click
Dim n As String
n = InputBox("Enter the position:")
TextBox2.Text = TextBox1.Text.Substring(0, n)
End Sub
12PA01

Page 25

8. STRING HANDLING FUNCTION

July 15, 2014

Private Sub concatecmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles concatecmd.Click
Dim a As String
a = InputBox("Enter the concatenation string:")
TextBox2.Text = String.Concat(TextBox1.Text, a)
End Sub
Private Sub removecmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles removecmd.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub containscmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles containscmd.Click
Dim n As String
n = InputBox("Enter the string")
TextBox2.Text = TextBox1.Text.Contains (n)
End Sub
Private Sub splitcmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
splitcmd.Click
Dim n, s () As String
Dim i As Integer
n = TextBox1.Text
s = n. Split ("")
For i = 0 To s.Length - 1
MessageBox.Show(s(i))
Next
End Sub
End Class

12PA01

Page 26

8. STRING HANDLING FUNCTION

July 15, 2014

Output:
~~~~~~

12PA01

Page 27

8. STRING HANDLING FUNCTION

July 15, 2014

Result:
~~~~~
Thus the string handling function program was successfully performed.

12PA01

Page 28

You might also like