Professional Documents
Culture Documents
GAD Slips-1
GAD Slips-1
Slip 1
Task 1 Write a program on Arithmetic Operations using MsgBox().
Ans)
Module Module1
Sub Main()
Dim num1 As Integer = 10
Dim num2 As Integer = 5
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 2
Task 1 Write a program using InputBox(), MsgBox() and perform various Arithmetic
Operations
Ans)
Module Module1
Sub Main()
Dim num1 As Integer
Dim num2 As Integer
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 3
Task 1 Write a program using if-else statement to find the number is even or odd.
Ans)
Module Module1
Sub Main()
Dim number As Integer
Console.Write("Enter a number: ")
number = Console.ReadLine()
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 4
Task 1 Write a program using Select Case statements to count the number of Vowels in
A to Z alphabets.
Ans)
Module Module1
Sub Main()
Dim alphabet As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim vowelsCount As Integer = 0
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 5
Task 1 Write a program for performing arithmetic operations using select case
Statement.
Ans)
Module Module1
Sub Main()
Dim num1, num2 As Integer
Dim operation As String
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 6
Task 1 Write a program using the While statement to print the prime numbers
between 1 to 100.
Ans)
Module Module1
Sub Main()
Dim number As Integer = 2
If isPrime Then
Console.WriteLine(number)
End If
number += 1
End While
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 7
Task 1 Write a program using While statement to print even-odd numbers between 1
to 50
Ans)
Module Module1
Sub Main()
Dim number As Integer = 1
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 8
Task 1 Write a program to change the background color of the form when the user
clicks on different buttons.
Ans)
Imports System.Windows.Forms
Output:
Task 2 Oral
Slip 9
Task 1 Write the program using Radio Button to change the bulb state ON/OFF.
Ans)
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As
EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked Then
PictureBox2.Show()
PictureBox1.Hide()
End If
End Sub
Output:
Task 2 Oral
Slip 10
Task 1 Write a program using Radio Button to display Gender.
Ans)
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As
EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked Then
Label2.Text = "Gender entered is male"
End If
End Sub
Output:
Task 2 Oral
Slip 11
Task 1 Write a program to select multiple subjects for single semester (Using Combo
Box).
Ans)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
ComboBox1.Items.Add("Mathematics")
ComboBox1.Items.Add("Physics")
ComboBox1.Items.Add("Chemistry")
ComboBox1.Items.Add("Biology")
ComboBox1.Items.Add("Computer Science")
End Sub
Output:
Task 2 Oral
Slip 12
Task 1 Write a program using picture box control to load an image at run time.
Ans)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
If System.IO.File.Exists(imagePath) Then
PictureBox1.Image = Image.FromFile(imagePath)
Else
MsgBox("Image file not found!")
End If
End Sub
End Class
Output:
Task 2 Oral
Slip 13
Task 1 Write a program to display the traffic signal using timer control.
Ans)
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles
Timer1.Tick
If PictureBox1.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = True
PictureBox3.Visible = False
ElseIf PictureBox2.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = True
ElseIf PictureBox3.Visible Then
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
End If
End Sub
Task 2 Oral
Slip 14
Task 1 Write a program using Error Provider for username and password
authentication.
Ans)
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Please Enter Your Name")
Else
ErrorProvider1.SetError(TextBox1, "")
End If
If TextBox2.Text = "" Then
ErrorProvider1.SetError(TextBox2, "Please Enter Your Password")
Else
ErrorProvider1.SetError(TextBox2, "")
End If
End Sub
End Class
Output:
Task 2 Oral
Slip 15
Task 1 Write a program to identify maximum number using parameterized Function.
Ans)
Module Module1
Sub Main()
Console.WriteLine("Enter three numbers:")
Dim num1 As Integer = Console.ReadLine()
Dim num2 As Integer = Console.ReadLine()
Dim num3 As Integer = Console.ReadLine()
Task 2 Oral
Slip 16
Task 1 Write a Program using Error Provider control to validate the Mobile Number
and Email-Id in GUI application.
Ans)
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim number As New Regex("\d{10}")
If number.IsMatch(TextBox1.Text) Then
ErrorProvider1.SetError(TextBox1, "")
MsgBox("Valid Phone Number")
Else
ErrorProvider1.SetError(TextBox1, "Invalid Phone Number")
End If
Dim regex As Regex = New Regex("^([\w-\.]+)@((\[[0 9]{1,3}\.[0
9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
)
Dim isValid As Boolean = regex.IsMatch(TextBox2.Text.Trim)
If Not isValid Then
ErrorProvider1.SetError(TextBox2, "Invalid E-mail ID")
Else
ErrorProvider1.SetError(TextBox2, "")
MsgBox("Valid E-Mail ID")
End If
End Sub
End Class
Output:
Task 2 Oral
Slip 17
Task 1 Write a Program on windows application for employee details using overriding
method.
Ans)
Module Module1
Sub Main()
Dim obj As New EmpInfo
obj.name = "John Doe"
obj.address = "123 Main St"
obj.EmpId = 101
obj.sallary = 50000
obj.JoinDate = Date.Now
obj.ShowInfo()
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 18
Task 1 Write a Program to identify Volume of Box Class With three data members as
length, breadth and height (Using Class and Object).
Ans)
Module Module1
Sub Main()
Dim myBox As New Box()
myBox.Length = 5
myBox.Breadth = 3
myBox.Height = 2
Console.WriteLine("Volume of the box: " & myBox.CalculateVolume())
Console.ReadLine()
End Sub
Task 2 Oral
Slip 20
Task 1 Write a program for inheritance where Student is Child class and Faculty is
Parent Class (Take appropriate variables in Base and Derived Class).
Ans)
Module Module1
Sub Main()
Dim student As New Student("John Doe", "CS", 20)
Dim faculty As New Faculty("Dr. Smith", "Mathematics", 40)
Console.ReadLine()
End Sub
Task 2 Oral
Slip 21
Task 1 Write a program for Student Registration using Exception Handling .
Ans)
Module Module1
Sub Main()
Try
Console.WriteLine("Enter Student Name:")
Dim name As String = Console.ReadLine()
Console.ReadLine()
End Sub
Public Sub New(ByVal name As String, ByVal age As Integer, ByVal email As
String)
If age < 18 Or age > 100 Then
Throw New ArgumentException("Age must be between 18 and 100.")
End If
Me.Name = name
Me.Age = age
Me.Email = email
End Sub
End Class
End Module
Task 2 Oral
Slip 22
Task 1 Write a program for Recursion using a function.
Ans)
Module Module1
Sub Main()
Console.WriteLine("Enter a number:")
Dim number As Integer = Console.ReadLine()
Console.WriteLine("Factorial : " & Factorial(number))
Console.ReadLine()
End Sub
Task 2 Oral
Slip 23
Task 1 Write a program to perform method Overloading as addition of two and three
numbers.
Ans)
Module Module1
Sub Main()
Dim result1 As Integer = Add(5, 10)
Console.WriteLine("Addition of two numbers: " & result1)
Console.ReadLine()
End Sub
Task 2 Oral
Slip 25
Task 1 Write a program using for-next loop statements to find the Armstrong numbers
between 1 to 500.
Ans)
Module Module1
Sub Main()
Dim number, digit, sum As Integer
Console.WriteLine("Armstrong Numbers Between 1 to 500:")
For number = 1 To 500
Dim tempNumber As Integer = number
sum = 0
While tempNumber > 0
digit = tempNumber Mod 10
sum += digit * digit * digit
tempNumber \= 10
End While
If number = sum Then
Console.WriteLine(number)
End If
Next
Console.ReadLine()
End Sub
End Module
Task 2 Oral
Slip 26
Task 1 Write a program for database connectivity and perform Insert, Update
commands for data in the access database.
Ans)
Task 2 Oral