You are on page 1of 4

5.

CONCATENATE THE TWO STRING July 3, 2014



12PA01 Page 13

Aim:
~~~~
To write a program to perform concatenate to the given two 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 and assign i variable as 0.
Step5: Get a two Input String in array variable .Using for each loop to assign
ch=str and another for each to loop to assign a ch1 ch1 =str1 and increment
i variable by 1.
Step6: Assign k value as 0, Using for loop and check condition as j<t.
Step7: Finally the output is stored in the array as ch2.
Step8: End of the program.










5. CONCATENATE THE TWO STRING July 3, 2014

12PA01 Page 14


Coding:
~~~~~~
Module Module1

Sub Main()
Dim a, b As String
Dim i, j, k, t As Integer
Dim ch(20), ch1(20), ch2(30) As Char
Console.WriteLine("Concatenation of the string")
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~")
Console.WriteLine("Input")
Console.WriteLine("*****")
Console.WriteLine("Enter the first string :")
a = Console.ReadLine()
Console.WriteLine("Enter the second string :")
b = Console.ReadLine()
i = 0
For Each element As Char In a
ch = a
i = i + 1
Next
t = i
For Each element1 As Char In b
ch1 = b
i = i + 1
Next
k = 0
For j = 0 To i - 1
If j < t Then
ch2(j) = ch(j)
Else
ch2(j) = ch1(k)
k = k + 1
End If
Next
Console.WriteLine("Output")
5. CONCATENATE THE TWO STRING July 3, 2014

12PA01 Page 15


Console.WriteLine("******")
Console.WriteLine(ch2)
Console.ReadKey()
End Sub
End Module






















5. CONCATENATE THE TWO STRING July 3, 2014

12PA01 Page 16


Output:
******

Concatenation of the string
~~~~~~~~~~~~~~~~~~~~~
Input
*****
Enter the first string:
hai
Enter the second string:
anjac
Output
******
haianjac











Result:
*****
Thus the concatenation to the given string program was successfully performed.

You might also like