Program to Create a VB.NET desktop application to check the string/char exists in an entered name.

Program UI :

141

 

Program Code :

Public Class Searching

Private Sub btnExit_Click(sender AsObject, e AsEventArgs) HandlesbtnExit.Click

Close()

End Sub

Private Sub btnClear_Click(sender AsObject, e AsEventArgs) HandlesbtnClear.Click

txtChrStr.Clear()

txtSearch.Clear()

End Sub

 

PrivateSubbtnSearch_Click(sender AsObject, e AsEventArgs) HandlesbtnSearch.Click

Dim Str, Search As String

Dim Len1, Len2, i, f AsInteger

f = 0

Str = txtChrStr.Text

Search = txtSearch.Text

Len1 = Str.Length

Len2 = Search.Length

Fori = 1 To Len1

If Search = Mid(Str, i, Len2) Then

f = 1

EndIf

Next

 

If f = 1 Then

MsgBox(“Exist !!!”)

Else

MsgBox(“Not Exist !!!”)

End If

End Sub

 

End Class

Output:

14

 

 

Advertisements

Program to Create a VB.NET desktop application for determining details of selected date using datetimepicker

Program UI:

aa

Program Code:

Public Class Programmingfromscratch

PrivateSub DateTimePicker1_ValueChanged(sender AsObject, e AsEventArgs) Handles DateTimePicker1.ValueChanged

DateTimePicker1.CalendarForeColor = Color.Red

txtDay.Text = DateTimePicker1.Value.DayOfWeek.ToString()

txtDate.Text = DateTimePicker1.Value.Day

txtMonth.Text = DateTimePicker1.Value.Month

txtYear.Text = DateTimePicker1.Value.Year

txtHour.Text = DateTimePicker1.Value.Hour

txtMinute.Text = DateTimePicker1.Value.Minute

TxtSecond.Text = DateTimePicker1.Value.Second

EndSub

PrivateSubbtnClr_Click(sender AsObject, e AsEventArgs) HandlesbtnClr.Click

txtDay.Clear()

txtDate.Clear()

txtMonth.Clear()

txtYear.Clear()

txtHour.Clear()

txtMinute.Clear()

TxtSecond.Clear()

EndSub

PrivateSubbtnCancel_Click(sender AsObject, e AsEventArgs) HandlesbtnCancel.Click

Me.Close()

EndSub

 

EndClass

Output :

aa

Program to convert the Case of a String in VB.NET

Mid() in Visual Basic.net is a string function that is used to extract a copy of                                     a character or set of characters from a string.

Syntax:
Function Mid( ByVal Str As String, ByVal Start As Integer,
Optional ByVal Length As Integer) As String

In the above syntax Str specifies the string from which the characters to be extracted from the starting position specified using Start, until the specifed Length of characters.

Program UI:

Screenshot (18).png

Program Code:

Public Class Task2

Private Sub btnoutput_Click(sender As Object, e As EventArgs) Handles btnoutput.Click
Dim len, i As Integer
Dim s, c As String
s = Textname.Text
len = s.Length
For i = 1 To len
c = Mid(s, i, 1)
If Asc(c) > 90 And Asc(c) < 123 Then
Textoutput.AppendText(UCase(c))
Else
Textoutput.AppendText(LCase(c))
End If
Next
End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
Textname.Clear()
Textoutput.Clear()
End Sub
End Class

Output:

Screenshot (17).png

Program to find the Case of a Chatacter in VB.NET

In this Program we are going to enter a Character and Display the CASE of the Character on Button Click on TextBox.

Program UI:

Screenshot (19)

Program Code :

Public Class Programmingfromscratch
Dim c As Integer

Private Sub btncheck_Click(sender As Object, e As EventArgs) Handles btncheck.Click
c = Asc(Textchar1.Text)
If (c >= 64 And c <= 91) Then  ‘ASCII VALUE
Textchar2.Text = “UPPER”
ElseIf (c >= 96 And c <= 122) Then
Textchar2.Text = “LOWER”
Else
Textchar2.Text = “Other Character”
End If

End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click 
Textchar2.Text = “”
Textchar1.Text = “”
End Sub

End Class

Output:

Screenshot (20)

Program to check whether a character is vowel or not in VB.NET

In this program we are going to check whether a character is vowel or not and display the result in a Label(i.e label3)  on Button Click

Program UI:

Screenshot (15)

Program Code:

Public Class programmingfromscratch
Dim a As Char

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
a = UCase(TextBox1.Text)
If a = “A” Or a = “E” Or a = “I” Or a = “O” Or a = “U” Then
Label3.Text = “Vowel”
Else
Label3.Text = “Not Vowel”
End If
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label3.Text = “”
TextBox1.Text = “”

End Sub

End Class

 

Output:

Screenshot (16).png

Program to implement calculator in VB.NET

Program UI:

Screenshot (13)

Program Code :

Public Class calculator
Dim a As Double
Dim b As Double
Dim c As String
Dim f As Integer
Dim d As Integer

Private Sub Numer1_Click(sender As Object, e As EventArgs) Handles Numer1.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “1”
Else
TextBox1.Text += “1”
End If
f = 0
d = 0

End Sub

Private Sub Numer2_Click(sender As Object, e As EventArgs) Handles Numer2.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “2”
Else
TextBox1.Text += “2”
End If
f = 0
d = 0
End Sub

Private Sub Numer3_Click(sender As Object, e As EventArgs) Handles Numer3.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “3”
Else
TextBox1.Text += “3”
End If
f = 0
d = 0
End Sub

Private Sub Numer4_Click(sender As Object, e As EventArgs) Handles Numer4.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “4”
Else
TextBox1.Text += “4”
End If
f = 0
d = 0
End Sub

Private Sub Numer5_Click(sender As Object, e As EventArgs) Handles Numer5.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “5”
Else
TextBox1.Text += “5”
End If
f = 0
d = 0
End Sub

Private Sub Numer6_Click(sender As Object, e As EventArgs) Handles Numer6.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “6”
Else
TextBox1.Text += “6”
End If
f = 0
d = 0
End Sub

Private Sub Numer7_Click(sender As Object, e As EventArgs) Handles Numer7.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “7”
Else
TextBox1.Text += “7”
End If
f = 0
d = 0
End Sub

Private Sub Numer8_Click(sender As Object, e As EventArgs) Handles Numer8.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “8”
Else
TextBox1.Text += “8”
End If
f = 0
d = 0
End Sub

Private Sub Numer9_Click(sender As Object, e As EventArgs) Handles Numer9.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “9”
Else
TextBox1.Text += “9”
End If
f = 0
d = 0
End Sub

Private Sub Numer0_Click(sender As Object, e As EventArgs) Handles Numer0.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “0”
Else
TextBox1.Text += “0”
End If
f = 0
d = 0
End Sub

Private Sub Dot_Click(sender As Object, e As EventArgs) Handles Dot.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “.”
Else
TextBox1.Text += “.”
End If
f = 0
d = 0
End Sub

Private Sub Bmod_Click(sender As Object, e As EventArgs) Handles Bmod.Click
a = TextBox1.Text
c = “mod”
d = 1
End Sub

Private Sub Add_Click(sender As Object, e As EventArgs) Handles Add.Click
a = TextBox1.Text
c = “add”
d = 1
End Sub

Private Sub min_Click(sender As Object, e As EventArgs) Handles min.Click
a = TextBox1.Text
c = “min”
d = 1
End Sub

Private Sub mul_Click(sender As Object, e As EventArgs) Handles mul.Click
a = TextBox1.Text
c = “mul”
d = 1
End Sub

Private Sub div_Click(sender As Object, e As EventArgs) Handles div.Click
a = TextBox1.Text
c = “div”
d = 1
End Sub

Private Sub equal_Click(sender As Object, e As EventArgs) Handles equal.Click
b = TextBox1.Text
f = 1
If c = “add” Then
TextBox1.Text = a + b
End If
If c = “min” Then
TextBox1.Text = a – b
End If
If c = “mul” Then
TextBox1.Text = a * b
End If
If c = “div” Then
TextBox1.Text = a / b
End If
If c = “mod” Then
TextBox1.Text = a Mod b
End If

End Sub

Private Sub Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click
a = 0
b = 0
TextBox1.Text = “”
End Sub
End Class

Screenshot (14)

 

Program to add two numbers in VB.NET

In this program we will take two numbers as input in TextBox and display the addition of numbers in a MessageBox on Button Click.

Program UI:

Screenshot (10).png

Program Code:

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
MessageBox.Show(“Addition :” + (num1 + num2).ToString)

‘coversion of double value to string

End Sub
End Class

Output:

Screenshot (11).png