Replace : Replace Function in VB.NET is used to replace a substring by another substring for every time the same substring found in the string.This function is case sensitive. For eg. string 'This is Visual Basic application', 'Visual Basic' is replaced with 'VB.NET' are shown given below:-
Dim strg As String = "This is Visual Basic application"
MsgBox(Replace(strg, "Visual Basic", "VB.NET"))
End Sub
StrComp : StrComp Function in VB.NET is used to compare two strings to return values '-1', '1', '0' based
on the value. In this function optional
comparison method can have Binary or Text for binary and text comparison. For string comparison False it returns '-1', True returns '0' and type mismatch returns '1' are shown given below:-
Public Sub Strg_comp()
Dim Str1 As String = "Google.com"
Dim Str2 As String = "google.com"
Dim Str3 As String = "Google.com"
Dim a As Integer = 5
MsgBox("Result of string comparison is:: " & StrComp(Str1, Str2, CompareMethod.Binary))
MsgBox("Result of string comparison is:: " & StrComp(Str1, Str3, CompareMethod.Binary))
MsgBox("Result of string comparison is:: " & StrComp(Str1, a, CompareMethod.Binary))
End Sub
Dim Str1 As String = "Google.com"
Dim Str2 As String = "google.com"
Dim Str3 As String = "Google.com"
Dim a As Integer = 5
MsgBox("Result of string comparison is:: " & StrComp(Str1, Str2, CompareMethod.Binary))
MsgBox("Result of string comparison is:: " & StrComp(Str1, Str3, CompareMethod.Binary))
MsgBox("Result of string comparison is:: " & StrComp(Str1, a, CompareMethod.Binary))
End Sub
StrReverse : StrReverse Function in VB.NET is used to return a string with characters in Reverse order. For eg. string contains value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' return a string 'ZYXWVUTSRQPONMLKJIHGFEDCBA' are shown given below:-
Public Sub Strg_reverse()
Dim Str As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MsgBox("Reversed string is:: " & StrReverse(Str))
Dim Str As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MsgBox("Reversed string is:: " & StrReverse(Str))
End Sub
No comments:
Post a Comment