KEMBAR78
Multimedia Lab | PDF | Multiplication | Computer Programming
0% found this document useful (0 votes)
447 views20 pages

Multimedia Lab

TOC Lab Note

Uploaded by

Noor Alamin 99
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
0% found this document useful (0 votes)
447 views20 pages

Multimedia Lab

TOC Lab Note

Uploaded by

Noor Alamin 99
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/ 20

INDEX

No Problem Name Page

01 Write a program to changing the transparent color in visual basic. 01

02 Write a program to design a digital clock in VB. 02

03 Write a program for a running traffic light application. 03

04 Write a program to convert the temperature from F to C & C to F using the option button 04
control.

05 Write a program to print the color name according the user. 06

06 Write a program to display the Full name and prints “Hello World” to the screen and waits for 07
any to be press to terminate program.

07 Write a program to display the words of a string in separate lines. 08

08 Write a program to find out the EVEN and ODD number. 09

09 Write a program to add the two numbers. 10

10 Write a program that simulates a sign in process. If the username and password are correct, 11
sign in is successful else sign in failed.

11 Write a Visual Basic application program that inputs a student numeric grade and turns out 12
the letter grade depending on following instructions.
a. Letter Grade A: Equals to or greater than 80
b. Letter Grade B: Equals to and greater than 70 and less than 80.
c. Letter Grade C: Equals to and greater than 60 and less than 70.
d. Letter Grade D: Equals to and greater than 50 and less than 60.
e. Letter Grade E: Less than 50.

12 Write a Visual Basic application program that makes mathematical calculations like +, -, *, /, 13
sqrt etc. When the program starts a list of mathematical expressions should be appears on
the top of the screen and user should enter the number first to select operation and then
input numbers. After that, program should show result and wait for user to press any to
terminate program.
a. 1- Addition (+)
b. 2- Subtraction (-)
c. 3- Multiplication (*)
d. 4- Division (/)
e. 5- Square Root

13 Write a Visual Basic to calculate the commission based on sales volume attained. Let's say 18
the commission structure is laid out as in the table below:

Sale Volume($) Commission(%)

<5000 0

5000-9999 5

1000-14999 10

15000-19999 15

20000 and above 20


Problem 1: Write a program to changing the transparent color in visual basic.

FORM:

PROGRAM:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Panel1.BackColor = Color.Red
Panel2.BackColor = Color.Blue
Panel3.BackColor = Color.Green
Panel4.BackColor = Color.Black
End Sub
End Class

OUTPUT:

1
Problem 2:Write a program to design a digital clock in VB.

PROGRAM:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Start()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick


Label1.Text = DateAndTime.Now
End Sub
End Class

OUTPUT:

2
Problem 3: Write a program for a running traffic light application.
FORM:

PROGRAM:
Public Class Form1
Dim c As Integer
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If c Mod 3 = 0 Then
Panel1.BackColor = Color.Red
Panel2.BackColor = Color.Gray
Panel3.BackColor = Color.Gray
ElseIf c Mod 3 = 1 Then
Panel1.BackColor = Color.Gray
Panel2.BackColor = Color.Yellow
Panel3.BackColor = Color.Gray
Else
Panel1.BackColor = Color.Gray
Panel2.BackColor = Color.Gray
Panel3.BackColor = Color.Green
End If
c=c+1
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 500
Timer1.Start()
c=0
End Sub
End Class

3
OUTPUT:

Problem 4: Write a program to convert the temperature from F to C & C to F using


the option button control.

FORM:

4
PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim temp As Double

If RadioButton1.Checked = True Then


temp = Val(TextBox1.Text)
temp = ((temp * 9) / 5) + 32
TextBox2.Text = temp
Else
temp = Val(TextBox2.Text)
temp = (5 * (temp - 32)) / 9
TextBox1.Text = temp
End If

End Sub

End Class

OUTPUT:

5
Problem 5:Write a program to print the color name according the user.

FORM:

PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ColorDialog1.ShowDialog()
Dim res As DialogResult
If res.OK Then
Label1.Text = ColorDialog1.Color.Name
End If
End Sub
End Class

OUTPUT:

6
Problem 6: Write a program to display the Full name and prints “Hello World” to the
screen and waits for any to be press to terminate program

FORM:

PROGRAM:
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Application.Exit()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


TextBox3.Text = TextBox1.Text + " " + TextBox2.Text + " Hello World"
End Sub
End Class

OUTPUT:

7
Problem 7: Write a program to display the words of a string in separate lines.

FORM:

PROGRAM:
Imports System.Xml

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str() As String
str = TextBox1.Text.Split(" ")
TextBox2.Text = String.Join(Environment.NewLine, str)
End Sub
End Class

OUTPUT:

8
Problem 8: Write a program to find out the EVEN and ODD number.

FORM:

PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = Val(TextBox1.Text)
If TextBox1.Text = "" Then
TextBox2.Text = "Please enter a valid number"
ElseIf a Mod 2 = 0 Then
TextBox2.Text = "Even"
Else
TextBox2.Text = "Odd"
End If
End Sub
End Class
OUTPUT:

9
Problem 9: Write a program to add the two numbers.

FORM:

PROGRAM:
Public Class Form1
Private Sub Result_Click(sender As Object, e As EventArgs) Handles Result.Click
Dim a As Integer
a = Val(TextBox1.Text)
Dim b As Integer
b = Val(TextBox2.Text)
Dim sum As Integer
sum = a + b
TextBox3.Text = sum.ToString
End Sub
End Class
OUTPUT:

10
Problem 10:Write a program that simulates a sign in process. If the username and
password are correct, sign in is successful else sign in failed.

FORM:

PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As String
a = TextBox1.Text
Dim b As String
b = TextBox2.Text
If a = "admin" And b = "password" Then
MsgBox("Login Successful")
Else
MsgBox("Wrong Password or user id")
End If
End Sub
End Class
OUTPUT:

11
Problem 11:.Write a Visual Basic application program that inputs a student numeric
grade and turns out the letter grade depending on following instructions.
a. Letter Grade A: Equals to or greater than 80
b. Letter Grade B: Equals to and greater than 70 and less than 80.
c. Letter Grade C: Equals to and greater than 60 and less than 70.
d. Letter Grade D: Equals to and greater than 50 and less than 60.
e. Letter Grade E: Less than 50.

FORM:

PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = Val(TextBox1.Text)
Dim s As String
If a >= 80 Then
s = "A"
ElseIf a >= 70 Then
s = "B"
ElseIf a >= 60 Then
s = "C"
ElseIf a >= 50 Then
s = "D"
Else s = "E"
End If
TextBox2.Text = s
End Sub
End Class

12
OUTPUT:

Problem 12: Write a Visual Basic application program that makes mathematical
calculations like +, -, *, /, sqrt etc. When the program starts a list of mathematical
expressions should be appears on the top of the screen and user should enter the number
first to select operation and then input numbers. After that, program should show result
and wait for user to press any to terminate program.
a. 1- Addition (+)
b. 2- Subtraction (-)
c. 3- Multiplication (*)
d. 4- Division (/)
e. 5- Square Root.

FORM:

13
PROGRAM:
Public Class Form1
Dim Op As String
Dim expression As String
Dim expressionCal As String
Dim ans As Integer
Dim number As Double
Dim cnt As Integer
Dim flg As Boolean
Private Sub Calculate_button_Click(sender As Object, e As EventArgs) Handles
Calculate_button.Click
checkpreroot()
number = 0
' Dim expression As String = "2 + 3 * 4" ' Your mathematical expression
Dim result As Object = New DataTable().Compute(expressionCal, Nothing)

' You can convert the result to the appropriate data type (e.g., Double)
Dim finalResult As Double = Convert.ToDouble(result)

TextBox2.Text = finalResult.ToString() ' Display the result in a TextBox


'Label1.Text = expression
Op = Nothing
expression = Nothing
expressionCal = Nothing
number = 0
End Sub

Private Sub upadatedisplay()


TextBox1.Text = expression
End Sub
Private Sub checkpreroot()
Dim pw As Integer
pw = Math.Pow(10, cnt)
cnt = 0
number = number / pw
' MsgBox(number)
If Op = "√" Then
Dim squareRoot As Double = Math.Sqrt(number)
number = squareRoot
End If
expressionCal += number.ToString
End Sub
Private Sub addition_Click(sender As Object, e As EventArgs) Handles addition.Click
checkpreroot()
number = 0
expressionCal += "+"
expression += "+"
Op = "+"
flg = False

14
upadatedisplay()
End Sub

Private Sub subtraction_Click(sender As Object, e As EventArgs) Handles subtraction.Click


checkpreroot()
number = 0
expressionCal += "-"
expression += "-"
Op = "-"
flg = False
upadatedisplay()
End Sub

Private Sub multiplication_Click(sender As Object, e As EventArgs) Handles


multiplication.Click
checkpreroot()
number = 0
expressionCal += "*"
expression += "*"
Op = "*"
flg = False
upadatedisplay()
End Sub

Private Sub division_Click(sender As Object, e As EventArgs) Handles division.Click


checkpreroot()
number = 0

expressionCal += "/"
expression += "/"
Op = "/"
flg = False
upadatedisplay()
End Sub

Private Sub square_root_Click(sender As Object, e As EventArgs) Handles


square_root.Click
expression += "√"
Op = "√"
flg = False
upadatedisplay()
End Sub

Private Sub ONE_Click(sender As Object, e As EventArgs) Handles ONE.Click

checkdot()
expression += "1"
number = number * 10 + 1
upadatedisplay()
End Sub

15
Private Sub TWO_Click(sender As Object, e As EventArgs) Handles TWO.Click

checkdot()
expression += "2"
number = number * 10 + 2
upadatedisplay()
End Sub

Private Sub THREE_Click(sender As Object, e As EventArgs) Handles THREE.Click


checkdot()
expression += "3"
number = number * 10 + 3
upadatedisplay()
End Sub

Private Sub FOUR_Click(sender As Object, e As EventArgs) Handles FOUR.Click


checkdot()
expression += "4"
number = number * 10 + 4
upadatedisplay()
End Sub

Private Sub FIVE_Click(sender As Object, e As EventArgs) Handles FIVE.Click


checkdot()
expression += "5"
number = number * 10 + 5
upadatedisplay()
End Sub

Private Sub SIX_Click(sender As Object, e As EventArgs) Handles SIX.Click

checkdot()
expression += "6"
number = number * 10 + 6
upadatedisplay()
End Sub

Private Sub SEVEN_Click(sender As Object, e As EventArgs) Handles SEVEN.Click


checkdot()
expression += "7"
number = number * 10 + 7
upadatedisplay()
End Sub

Private Sub EIGHT_Click(sender As Object, e As EventArgs) Handles EIGHT.Click


checkdot()
expression += "8"
number = number * 10 + 8
upadatedisplay()

16
End Sub

Private Sub NINE_Click(sender As Object, e As EventArgs) Handles NINE.Click


checkdot()
expression += "9"
number = number * 10 + 9
upadatedisplay()
End Sub

Private Sub ZERO_Click(sender As Object, e As EventArgs) Handles ZERO.Click


checkdot()
expression += "0"
number = number * 10 + 0
upadatedisplay()
End Sub

Private Sub checkdot()


If flg Then
cnt = cnt + 1
End If
End Sub

Private Sub Dot_Click(sender As Object, e As EventArgs) Handles Dot.Click


' number = number / 10
'If expression.Length > 0 Then
'ression = expression.Remove(expression.Length - 1)
' End If
expression += "."
flg = True
upadatedisplay()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


' InitializeComponent()
number = 0
cnt = 0
End Sub

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles


TextBox2.TextChanged
End Sub

Private Sub clear_button_Click(sender As Object, e As EventArgs) Handles


clear_button.Click
Op = Nothing
expression = Nothing
expressionCal = Nothing
number = 0
upadatedisplay()
End Sub
End Class

17
OUTPUT:

Problem 13: Write a Visual Basic to calculate the commission based on sales volume
attained. Let's say the commission structure is laid out as in the table below:

Sale Volume($) Commission(%)

<5000 0

5000-9999 5

1000-14999 10

15000-19999 15

20000 and above 20

FORM:

18
PROGRAM:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = Val(TextBox1.Text)
Dim s As String
If a >= 20000 Then
s = 20
ElseIf a >= 15000 Then
s = 15
ElseIf a >= 10000 Then
s = 10
ElseIf a >= 5000 Then
s=5
Else s = 0
End If
TextBox2.Text = s
End Sub
End Class

OUTPUT:

19

You might also like