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
No comments:
Post a Comment