100% found this document useful (1 vote)
777 views11 pages

Solved VB - NET Lab List

The document contains code snippets for 10 different VB.Net programs. The programs include: 1) moving text from left to right continuously, 2) blinking an image, 3) displaying a multiplication table from user input, 4) changing a component color, 5) adding controls dynamically, 6) handling divide by zero exceptions, 7) calculating employee salary, 8) extracting date components, and 10) building a multiple choice quiz application. The code demonstrates common tasks like handling events, user input, exceptions, control properties and dynamic form construction.

Uploaded by

Ravi Kumar
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)
777 views11 pages

Solved VB - NET Lab List

The document contains code snippets for 10 different VB.Net programs. The programs include: 1) moving text from left to right continuously, 2) blinking an image, 3) displaying a multiplication table from user input, 4) changing a component color, 5) adding controls dynamically, 6) handling divide by zero exceptions, 7) calculating employee salary, 8) extracting date components, and 10) building a multiple choice quiz application. The code demonstrates common tasks like handling events, user input, exceptions, control properties and dynamic form construction.

Uploaded by

Ravi Kumar
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

1] Vb.

Net program to move the text continuously from left to right

(a) Design

b) Code

Public Class Form1


Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles [Link]

If [Link] >= [Link] Then


[Link] = -100
Else
[Link] = [Link] + 10
End If

End Sub

End Class

2 ] [Link] program for blinking an image

a) Design
b) Code

Public Class Form1


Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles [Link]

If [Link] = True Then


[Link] = False
Else
[Link] = True
End If

End Sub
End Class

3] [Link] program to accept a number from the user through input box and display its
multiplication table in the list box

a) Design
b) Code

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

[Link]()

Dim n As Integer
Dim i As Integer

n = InputBox("Enter Number to Dislay Multiplication table", "Multilication Table", 2,


150, 180)

For i = 1 To 10
[Link](n & " * " & i & " =" & i * n)

Next

End Sub
End Class

4 ] Write a [Link] program to change the color of the component


a) Design

b) Code

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

Dim objColorDlg As New ColorDialog

If [Link] = [Link] Then


[Link] = [Link]
End If
End Sub
End Class

5] Write a [Link] program to add 2 textboxex, 2 label buttons and 1 button at runtime
a) Design
c) code

Public Class Form1


Dim t1, t2 As New TextBox
Dim l1, l2 As New Label

Dim c1 As New ComboBox


Dim d As New Button

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

[Link](l1)
[Link](l2)
[Link](t1)
[Link](t2)

[Link](c1)
[Link](d)

[Link] = 100
[Link] = 60
[Link] = 100
[Link] = 100
[Link] = 200
[Link] = 50
[Link] = 200
[Link] = 100

[Link] = 300
[Link] = 200
[Link] = "Input 1"
'
[Link] = "Input 2"
End Sub
End Class

6] Write a [Link] program to accept 2 numbers in a textboxes and handle DivideByZero


exception

a) design

b) Code

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

Dim ans, n1, n2 As Double

n1 = CDbl([Link])
n2 = CDbl([Link])
Try
ans = n1 \ n2
Catch ex As DivideByZeroException

MsgBox("Divide By Zero Exception Caughted")

Finally
[Link] = ans
End Try

End Sub
End Class

7] Write a [Link] program to design following screen, accept the details from the user.
Clicking on Submit button Net Salary should be calculated and displayed into the
TextBox. Display the MessageBox informing the Name and Net Salary of employee.
a) design

c) Code

Public Class Form1


Private Sub cmdsalary_Click(sender As Object, e As EventArgs) Handles
[Link]
Dim HRA, DA, PF, IT, Gross, NetS As Double
Dim basic As Double
basic = CDbl([Link])
Select Case basic
Case 10000 To 20000
DA = basic * 0.1
HRA = basic * 0.12
IT = 0
PF = 1200
Case 20000 To 30000
DA = basic * 0.15
HRA = basic * 0.17
IT = 1000
PF = 1400

Case 30000 To 50000


DA = basic * 0.2
HRA = basic * 0.22
IT = 1500
PF = 1600
Case Is >= 50000
DA = basic * 0.25
HRA = basic * 0.27
IT = 2500
PF = 1800
Case Else
MsgBox("Invalid Basic")
End Select
Gross = basic + DA + HRA
NetS = Gross - IT - PF

[Link] = Gross
[Link] = NetS

MsgBox("Name = " & [Link] & "and Net Salary = " & NetS)

End Sub

Private Sub cmdclear_Click(sender As Object, e As EventArgs) Handles [Link]


[Link] = ""
[Link] = ""
[Link] = ""
'[Link] = ""
'[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""

End Sub

Private Sub cmdend_Click(sender As Object, e As EventArgs) Handles [Link]


End
End Sub
End Class

8] Design a [Link] form to pick a date from DateTimePicker Control and display day,
month and year in separate text boxes
a) Design

b) Code

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

MsgBox([Link])

[Link] = [Link]

[Link] = Month([Link])

[Link] = Year([Link])
End Sub
End Class

10] Write a [Link] program to design the MCQ form, select the question number from
combo box that question will be displayed into textbox and the options for that
question will be displayed on four radio buttons, select option and click on submit
button result should be displayed in another textbox.

a) Design

b) Code

Public Class Form1


Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles [Link]

Select Case [Link]


Case 1
[Link] = "Who is the president of India"
[Link] = "A"
[Link] = "B"
[Link] = "Ramnath Kovind"
[Link] = "D"
Case 2
[Link] = "C++ is which type of language"
[Link] = "OOP"
[Link] = "B"
[Link] = "Ramnath Kovind"
[Link] = "D"
Case 3
[Link] = "Stack is also called as"
[Link] = "A"
[Link] = "B"
[Link] = "Ramnath Kovind"
[Link] = "LIFO"
End Select

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] = 1 Then
If [Link] = True Then
[Link] = "Correct"
Else
[Link] = "wrong answer, correct answer is : Ramanth Kovind"

End If
End If

If [Link] = 2 Then
If [Link] = True Then
[Link] = "Correct"
Else
[Link] = "wrong answer, correct answer is : OOP"

End If
End If
If [Link] = 3 Then
If [Link] = True Then
[Link] = "Correct"
Else
[Link] = "wrong answer, correct answer is : LIFO"

End If
End If
End Sub
End Class

You might also like