100% found this document useful (1 vote)
359 views

Practical Program

The document contains 9 VB.NET programs with examples of using controls like timers, listboxes, comboboxes and performing basic calculations. The programs cover tasks like designing a digital watch, adding/subtracting numbers, finding the smallest/greatest number, checking if a character is a vowel, and building a simple calculator.

Uploaded by

Pankaj Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
359 views

Practical Program

The document contains 9 VB.NET programs with examples of using controls like timers, listboxes, comboboxes and performing basic calculations. The programs cover tasks like designing a digital watch, adding/subtracting numbers, finding the smallest/greatest number, checking if a character is a vowel, and building a simple calculator.

Uploaded by

Pankaj Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.

NET PRACTICAL)

VB.NET PRACTICAL PROGRAM

1. Design the digital watch using Timer Control.

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick

Label1.Text = TimeOfDay

End Sub
End Class

2. W.A.P using ListBox and ComboBox.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ListBox1.SelectedIndexChanged

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
MessageBox.Show(ComboBox1.Text)

End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

3. WAP to ADD, SUBTRACT, MULTIPLY and DIVIDE any two numbers using input and Message
Box.
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

Text3.Text = Val(Text1.Text) + Val(Text2.Text)


MessageBox.Show(Text3.Text)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click

Text3.Text = Val(Text1.Text) - Val(Text2.Text)


MessageBox.Show(Text3.Text)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click

Text3.Text = Val(Text1.Text) * Val(Text2.Text)


MessageBox.Show(Text3.Text)
End Sub

Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button4.Click

Text3.Text = Val(Text1.Text) / Val(Text2.Text)


MessageBox.Show(Text3.Text)
End Sub
End Class

4. Write a program to find Smallest Number.


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click
Dim a, b, c As Integer
a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
If a < b Then
If a < c Then
MsgBox(a & "is the smalest number")
Else
MsgBox(c & "is the smalest number")
End If
Else
If b < c Then
MsgBox(b & "is the smalest number")
Else
MsgBox(c & "is the smalest number")

End If
End If
End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

5. Write a program to find Gratest Number.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim a, b, c As Integer
a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
If a > b Then
If a > c Then
MsgBox(a & "is the gratest number")
Else
MsgBox(c & "is the gratest number")

End If
Else
If b > c Then
MsgBox(b & "is the gratest number")
Else
MsgBox(c & "is the gratest number")
End If
End If

End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

6. write one TextBox and one Button. when you click Button, TextBox will show "hello world".
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

If TextBox1.Text = "hello" Then


Label1.Text = "world"
Else
Label1.Text = "wrong word"
End If

End Sub
End Class

7. W.A.P to print any number table with standard format.

Public Class Form1


Dim Num As Integer = 1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

Do While (Num <= 12)


ListBox1.Items.Add(Num & "*" & Val(TextBox1.Text) & "=" & Num * Val(TextBox1.Text))
Num += 1
Loop
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click

ListBox1.Items.Clear()
ListBox1.Refresh()
TextBox1.Text = ""
Num = 1
End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

8. Write a VB.NET program to accept any character from keyboard and Display whether it is
Vowel or Not Vowel.
Public Class Form1

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles lblResult.Click
End Sub

Private Sub btncheck_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btncheck.Click
Dim c As Char
c = UCase(txtchar.Text)
If c = "A" Or c = "E" Or c = "I" Or c = "O" Or c = "U" Then
lblResult.Text = "Vowel"
Else
lblResult.Text = "Not Vowel"
End If
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnclear.Click
txtchar.Clear()
lblResult.Text = "Vowel / Not Vowel"
End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

9. W.A.P for performing the function of a simple Calculator.


Public Class Form1
Dim str As String 'for operator like + - * /'
Dim str1 As Double
Dim str2 As Double
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btn1.Click
t1.Text += btn1.Text
End Sub

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn2.Click
t1.Text += btn2.Text
End Sub

Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn3.Click
t1.Text += btn3.Text
End Sub

Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn4.Click
t1.Text += btn4.Text
End Sub

Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn5.Click
t1.Text += btn5.Text
End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn6.Click
t1.Text += btn6.Text
End Sub

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn7.Click
t1.Text += btn7.Text
End Sub

Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn8.Click
t1.Text += btn8.Text
End Sub

Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn9.Click
t1.Text += btn9.Text
End Sub

Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btn0.Click
t1.Text += btn0.Text
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btndot.Click
t1.Text += btndot.Text
End Sub

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnadd.Click
str1 = Val(t1.Text)
t1.Text = " "
str = btnadd.Text

End Sub

Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnsub.Click
str1 = Val(t1.Text)
t1.Text = " "
str = btnsub.Text
End Sub

Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnmul.Click
str1 = Val(t1.Text)
t1.Text = " "
str = btnmul.Text
End Sub

Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btndiv.Click
str1 = Val(t1.Text)
t1.Text = " "
str = btndiv.Text
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnclear.Click
t1.Clear()
End Sub

Private Sub btnres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles btnres.Click
str2 = Val(t1.Text)
If str = "+" Then
t1.Text = str1 + str2
Else
str2 = Val(t1.Text)
If str = "-" Then
t1.Text = str1 - str2
Else
str2 = Val(t1.Text)
If str = "*" Then
t1.Text = str1 * str2
Else
str2 = Val(t1.Text)
If str = "/" Then
t1.Text = str1 / str2
End If
End If
End If
End If
End Sub
End Class

Prepared By-SONALI
SKILL WORLD COMPUTER EDUCATION CENTER (PGDCA-VB.NET PRACTICAL)

10. W.A.P for creating a new word Editor.


Imports System.IO

Public Class Form1

Private Sub FILE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles FILE.Click

End Sub

Private Sub SAVEASToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles SAVEASToolStripMenuItem.Click
Dim sfd As New SaveFileDialog
Dim sv As String
sfd.ShowDialog()
sv = sfd.FileName
Dim sw As New StreamWriter(sv)
sw.Write(RichTextBox1.Text)
sw.Close()

End Sub

Private Sub OPENToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles OPENToolStripMenuItem.Click
Dim ofd As New OpenFileDialog
Dim f1 As String
ofd.ShowDialog()
f1 = ofd.FileName
Dim sr As New StreamReader(f1)
RichTextBox1.Text = sr.ReadToEnd()
sr.Close()
End Sub
End Class

Prepared By-SONALI

You might also like