How to VB.NET String.Concat()

The Concat method in VB.NET's String Class is a powerful tool used for concatenating or combining two specified String objects into a single string. By utilizing the Concat method, you can seamlessly merge the contents of two strings, creating a new string that incorporates both.

Concat method

The Concat method takes two String objects as parameters and returns a new string that represents the concatenation of both input strings. The order in which you pass the parameters determines the order in which the strings are concatenated within the resulting string.

System.String.Concat(ByVal str1 As String, ByVal str2 As String) As String

String Concat method returns a new String

Parameters:
  1. String str1 : Parameter String
  2. String str2 : Parameter String
Returns:
  1. String : A new String retrun with str1 Concat with str2.

String.Concat() functionality proves useful when you need to join multiple strings together to form a more comprehensive string or when constructing dynamic text or messages. Whether you're combining variable values, user inputs, or fixed text, the Concat method offers a convenient solution for string concatenation.

Full Source VB.NET
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim str1 As String Dim str2 As String str1 = "Concat() " str2 = "Test" MsgBox(String.Concat(str1, str2)) End Sub End Class

Conclusion

The Concat method in the VB.NET String Class enables developers to effortlessly combine two specified String objects into a single string. This functionality enhances the convenience and efficiency of string concatenation, allowing for the seamless merging of string content in VB.NET applications.