String endswith, concat in VB.net
By: Issac
To check the whether the given string ends with specified string we use EndsWith method in String class
System.String.EndsWith (String suffix) as Boolean
Parameters:
Suffix – the suffix of the given string
Returns:
Boolean - Yes/No
If the String EndsWith the Parameter String it returns True
If the String doesnt EndsWith the Parameter String it return False
For ex : "This is a Test".EndsWith("Test") returns True
"This is a Test".EndsWith("is") returns False
Exceptions:
System.ArgumentNullException : If the argument is null
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
str = "GOD BLESS YOU"
If str.EndsWith("YOU") = True Then
MsgBox("The String EndsWith 'BOOKS' ")
Else
MsgBox("The String does not EndsWith 'BOOKS'")
End If
End Sub
End Class
When you execute the program you will get a message box like "The String EndsWith 'YOU' "
Concat in VB.NET String Class using for concat two specified String Object
System.String.Concat (ByVal str1 As String, ByVal str2 As String) As String
String Concat method returns a new String
Parameters:
• String str1
• String str2
Returns:
String: A new String retrun with str1 Concat with str2
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
When you run this source code you will get "Concat () Test " in message box.
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net