This document describes a program to concatenate two strings in VB.NET. It outlines 8 steps: 1) starting a new project, 2) declaring variables, 3) getting input strings, 4) assigning characters of the first string to an array, 5) assigning characters of the second string to another array, 6) using a for loop to concatenate the characters and store in a third array, 7) outputting the concatenated string, and 8) ending the program. The output shows the successful concatenation of the sample input strings "hai" and "anjac" into the single output string "haianjac".
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 ratings0% found this document useful (0 votes)
32 views4 pages
Concatenate The Two String July 3, 2014
This document describes a program to concatenate two strings in VB.NET. It outlines 8 steps: 1) starting a new project, 2) declaring variables, 3) getting input strings, 4) assigning characters of the first string to an array, 5) assigning characters of the second string to another array, 6) using a for loop to concatenate the characters and store in a third array, 7) outputting the concatenated string, and 8) ending the program. The output shows the successful concatenation of the sample input strings "hai" and "anjac" into the single output string "haianjac".
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/ 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.