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 Timer1.Tick
If Label1.Left >= Me.Width Then
Label1.Left = -100
Else
Label1.Left = Label1.Left + 10
End If
End Sub
End Class
2 ] Vb.Net program for blinking an image
a) Design
b) Code
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If PictureBox1.Visible = True Then
PictureBox1.Visible = False
Else
PictureBox1.Visible = True
End If
End Sub
End Class
3] Vb.Net 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 Button1.Click
ListBox1.Items.Clear()
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
ListBox1.Items.Add(n & " * " & i & " =" & i * n)
Next
End Sub
End Class
4 ] Write a VB.Net 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 Button1.Click
Dim objColorDlg As New ColorDialog
If objColorDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
Label1.BackColor = objColorDlg.Color
End If
End Sub
End Class
5] Write a VB.Net 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 Button1.Click
Controls.Add(l1)
Controls.Add(l2)
Controls.Add(t1)
Controls.Add(t2)
Controls.Add(c1)
Controls.Add(d)
l1.Left = 100
l1.Top = 60
l2.Left = 100
l2.Top = 100
t1.Left = 200
t1.Top = 50
t2.Left = 200
t2.Top = 100
c1.Left = 300
c1.Top = 200
l1.Text = "Input 1"
'
l2.Text = "Input 2"
End Sub
End Class
6] Write a VB.Net 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 Button1.Click
Dim ans, n1, n2 As Double
n1 = CDbl(TextBox1.Text)
n2 = CDbl(TextBox2.Text)
Try
ans = n1 \ n2
Catch ex As DivideByZeroException
MsgBox("Divide By Zero Exception Caughted")
Finally
TextBox3.Text = ans
End Try
End Sub
End Class
7] Write a Vb.net 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
cmdsalary.Click
Dim HRA, DA, PF, IT, Gross, NetS As Double
Dim basic As Double
basic = CDbl(txtbasic.Text)
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
lblGross.Text = Gross
lblNet.Text = NetS
MsgBox("Name = " & txtempname.Text & "and Net Salary = " & NetS)
End Sub
Private Sub cmdclear_Click(sender As Object, e As EventArgs) Handles cmdclear.Click
txtEmpID.Text = ""
txtempname.Text = ""
cmbDesg.Text = ""
'dtpDOB.Value = ""
'dtpDOJ.Value = ""
txtbasic.Text = ""
lblGross.Text = ""
lblNet.Text = ""
End Sub
Private Sub cmdend_Click(sender As Object, e As EventArgs) Handles cmdend.Click
End
End Sub
End Class
8] Design a Vb.net 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 Button1.Click
MsgBox(DateTimePicker1.Value)
TextBox1.Text = DateTimePicker1.Value.Day
TextBox2.Text = Month(DateTimePicker1.Value)
TextBox3.Text = Year(DateTimePicker1.Value)
End Sub
End Class
10] Write a Vb.net 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 ComboBox1.SelectedIndexChanged
Select Case ComboBox1.Text
Case 1
TextBox1.Text = "Who is the president of India"
RadioButton1.Text = "A"
RadioButton2.Text = "B"
RadioButton3.Text = "Ramnath Kovind"
RadioButton4.Text = "D"
Case 2
TextBox1.Text = "C++ is which type of language"
RadioButton1.Text = "OOP"
RadioButton2.Text = "B"
RadioButton3.Text = "Ramnath Kovind"
RadioButton4.Text = "D"
Case 3
TextBox1.Text = "Stack is also called as"
RadioButton1.Text = "A"
RadioButton2.Text = "B"
RadioButton3.Text = "Ramnath Kovind"
RadioButton4.Text = "LIFO"
End Select
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ComboBox1.SelectedItem = 1 Then
If RadioButton3.Checked = True Then
TextBox2.Text = "Correct"
Else
TextBox2.Text = "wrong answer, correct answer is : Ramanth Kovind"
End If
End If
If ComboBox1.SelectedItem = 2 Then
If RadioButton1.Checked = True Then
TextBox2.Text = "Correct"
Else
TextBox2.Text = "wrong answer, correct answer is : OOP"
End If
End If
If ComboBox1.SelectedItem = 3 Then
If RadioButton4.Checked = True Then
TextBox2.Text = "Correct"
Else
TextBox2.Text = "wrong answer, correct answer is : LIFO"
End If
End If
End Sub
End Class