VB.net Practical String Related
Public Class
Form6
'Two String Compare
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 = InputBox("Enter string1: ")
str2 = InputBox("Enter string2: ")
If str1 = str2 Then
MsgBox("Strings
are equal")
Else
MsgBox("Strings
are not equal")
End If
End Sub
'String Join using string.Join
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim str() As
String = {"Hello",
"how", "are",
"you"}
Dim result As
String
result = String.Join("_", str)
MsgBox(result)
End Sub
'String Compare using string.Compare
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim str1 As
String = "Hello"
Dim str2 As
String = "hello"
Dim str3 As
String = "Hello"
Dim ret As
Integer = 0
'ret = String.Compare(str1, str2)
'If ret = 0 Then
'
MsgBox("Strings matched")
'Else
'
MsgBox("Strings are different")
'End If
ret = String.Compare(str1, str3)
If ret = 0 Then
MsgBox("Strings
matched")
Else
MsgBox("Strings
are different")
End If
End Sub
'String Concat
using string.Concat
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
Dim str1 As
String = "Seema
"
Dim str2 As
String = "Pati
"
Dim str3 As
String
str3 = String.Concat(str1, str2)
MsgBox(str1)
MsgBox(str2)
MsgBox(str3)
End Sub
'String Copy using string.copy
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
Dim str1 As
String = "Hello
World"
Dim str2 As
String
str2 = String.Copy(str1)
MsgBox(str1)
MsgBox(str2)
End Sub
'Check number in
string
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
Dim num As
String
num = InputBox("Enter Any String")
Dim ret As
Boolean
ret = IsNumeric(num)
If (ret = True)
Then
MsgBox("Specified
string contains a number")
Else
MsgBox("Specified
string does not contain a number")
End If
End Sub
'check enter
value is pelindrome or not
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button7.Click
Dim r, s As
String
s = InputBox("Enter Any String")
r = StrReverse(s)
If s = r Then
MsgBox("String
Is Pelindrom")
Else
MsgBox("String
Is Not Pelindrom")
End If
End Sub
'Check Vowel or
consonent using select case
Private Sub
Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button8.Click
Dim ch As
Char
ch = InputBox("Enter Any
Character")
Select Case
ch
Case
"a", "i",
"u", "o",
"e"
MessageBox.Show("Small " + ch + "
Is Vowel")
Case
"A", "E",
"I", "O",
"E"
MessageBox.Show("Capital
" + ch + " Is Vowel")
Case Else
MessageBox.Show(ch
+ " Is Consonent")
End
Select
End Sub
'Display Date And Time From DTPICKER In Textbox
Private Sub
Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button9.Click
Dim d As
Date
d = DateTimePicker1.Value
TextBox1.Text = d.Day
TextBox2.Text = d.Month
TextBox3.Text = d.Year
End Sub
'Change Upper Case
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
Dim st As
String
st = TextBox4.Text
Dim st1 As
String
st1 = st.ToUpper
MessageBox.Show("String
" + st + " IS In Upper Case " + st1)
End Sub
'Change Lower
Case
Private Sub
Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button11.Click
Dim st As
String
st = TextBox4.Text
Dim st1 As
String
st1 = st.ToLower
MessageBox.Show("String
" + st + " IS In Upper Case " + st1)
End Sub
End Class


Welcome to OnlineGuru2020.blogspot.com, your number one source for all things related to Online Education. We're dedicated to providing you the very best of Digital Education, with an emphasis on E-notes,Download Links in PDF and youtube videos etc
OnlineGuru2020 Founded in [2020] by Sapan Kumar Das (Asst. Proff Ramchandi College Saraipali), OnlineGuru2020.blogspot.com has come a way from its beginnings .When I first started, my passion inspired me to start my own blog, seeing the need for students in lockdown2020
We hope you enjoy our products as much as we enjoy offering them to you. If you have any questions or comments, please don't hesitate to contact us.
Contact Datails:-
Mobile Number:-9826026747
Email:-sapam.online@gmail.com
Sincerely,
Sapan Kumar Das
.