Sie sind auf Seite 1von 8

Q6. A) WAP in VB.

NET to check the divisibility of a number by 2,3,5 by


windows form application?
CODE:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim a, b As Integer
a = TextBox1.Text()
If a Mod 2 = 0 Then
If a Mod 3 = 0 Then
If a Mod 5 = 0 Then
MsgBox("Number Is Divisible By All")
Else
MsgBox("Number Is Divisible By 2 And 3")
b = TextBox2.Text()
End If
ElseIf a Mod 5 = 0 Then
MsgBox("Number Is Divisible By 2 And 5")
Else
MsgBox("Number Is Divisible By 2 ")
b = TextBox2.Text()
End If
ElseIf a Mod 3 = 0 Then
If a Mod 5 = 0 Then
MsgBox("Number Is Divisible By 3 And 5")
Else
MsgBox("Number Is Divisible By 3 ")
b = TextBox2.Text()
End If
ElseIf a Mod 5 = 0 Then
MsgBox("Only By 5")
Else
MsgBox("Not By Any")
b = TextBox2.Text()
End If
End Sub
End Class

Hitesh
02117702014

OUTPUT:-

Q6. B) WAP in VB.NET to check the divisibility of a number by 2,3,5 by console


application?
Hitesh
02117702014

CODE:Module Module1
Sub Main()
Dim a As Integer
Console.WriteLine("Enter a number")
a = Console.ReadLine()
If a Mod 2 = 0 Then
If a Mod 3 = 0 Then
If a Mod 5 = 0 Then
Console.WriteLine("Number Is Divisible By All")
Else
Console.WriteLine("Number Is Divisible By 2 And 3")
End If
ElseIf a Mod 5 = 0 Then
Console.WriteLine("Number Is Divisible By 2 And 5")
Else
Console.WriteLine("Number Is Divisible By 2 ")
End If
ElseIf a Mod 3 = 0 Then
If a Mod 5 = 0 Then
Console.WriteLine("Number Is Divisible By 3 And 5")
Else
Console.WriteLine("Number Is Divisible By 3 ")
End If
ElseIf a Mod 5 = 0 Then
Console.WriteLine("Only By 5")
Else
Console.WriteLine("Not By Any")
End If
End Sub
End Module
OUTPUT:-

Q7. A) WAP in VB.NET to show the use of switch case by windows application?
Hitesh
02117702014

CODE:Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim grade As String
grade = TextBox1.Text
Select Case grade
Case "A"
MsgBox("High Distinction")
Case "A-"
MsgBox("Distinction")
Case "B"
MsgBox("Credit")
Case "C"
MsgBox("Pass")
Case Else
MsgBox("Fail")
End Select
End Sub
End Class
OUTPUT:-

Q7. B) WAP in VB.NET to show the use of switch case by console application?
CODE:Module Module1
Hitesh
02117702014

Sub Main()
Dim grade As String
Console.WriteLine("Enter your grade")
grade = Console.ReadLine()
Select Case grade
Case "A"
Console.WriteLine("High Distinction")
Case "A-"
Console.WriteLine("Distinction")
Case "B"
Console.WriteLine("Credit")
Case "C"
Console.WriteLine("Pass")
Case Else
Console.WriteLine("Fail")
End Select
End Sub
End Module
OUTPUT:-

Q8 WAP in VB.net to print table of a number using for loop by console


application?
Hitesh
02117702014

CODE:Module Module1
Sub Main()
Dim a, i, j, table As Integer
Console.WriteLine("Enter an number to print its Table")
a = Console.ReadLine()
Console.WriteLine("Enter upto which value you want print the Table")
i = Console.ReadLine()
For j = 1 To i Step 1
table = a * j
Console.WriteLine("{0} * {1} = {2}", a, j, table)
Next
End Sub
End Module
OUTPUT:-

Q9. ) WAP in VB.NET to find sum of rows in 2-d array by console application?
Hitesh
02117702014

CODE:Module Module1
Sub Main()
Dim arr(2, 3), sum(2) As Integer
Console.WriteLine("enter the numbers")
For a As Integer = 0 To 2 Step 1
For b As Integer = 0 To 3 Step 1
arr(a, b) = Console.ReadLine()
sum(a) += arr(a, b)
Next
Next
For a As Integer = 0 To 2
For b As Integer = 0 To 3
Console.Write(arr(a, b) & vbTab)
Next
Console.Write(sum(a))
Console.WriteLine()
Next
End Sub
End Module
OUTPUT:-

Q10. )WAP IN VB.NET to take input for a jagged array from user and print It by
console application?
CODE:Hitesh
02117702014

Module Module1
Sub Main()
Dim column, i, j As Integer
Dim a()() As Integer = New Integer(2)() {}
Console.WriteLine("enter the no of columns of jagged array")
For i = 0 To 2
Console.WriteLine("enter the number of columns for {0} row", i)
column = Console.ReadLine()
column = column - 1
a(i) = New Integer(column) {}
Next
Console.WriteLine("enter the elements of Jagged Array")
For i = 0 To 2
For j = a(i).GetLowerBound(0) To a(i).GetUpperBound(0)
a(i)(j) = Console.ReadLine()
Next
Next
Console.WriteLine("Jagged Array is ")
For i = 0 To 2
For j = a(i).GetLowerBound(0) To a(i).GetUpperBound(0)
Console.Write(a(i)(j))
Console.Write(vbTab)
Next
Console.WriteLine()
Next
End Sub
End Module
OUTPUT:-

Hitesh
02117702014

Das könnte Ihnen auch gefallen