Documente Academic
Documente Profesional
Documente Cultură
Net
Output
27
Devanshu
03213702014
Front End Design Tool VB.Net
Design
Coding
Public Class Form2
Dim t1 As Double
Dim sign As String
03213702014
Front End Design Tool VB.Net
End Sub
29
Devanshu
03213702014
Front End Design Tool VB.Net
30
Devanshu
03213702014
Front End Design Tool VB.Net
End Class
Output
31
Devanshu
03213702014
Front End Design Tool VB.Net
Q16: Design a simple application to change the background colors of form in which user enter the
RGB codes.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Me.BackColor = Color.FromArgb(CInt(TextBox1.Text), CInt(TextBox2.Text), CInt(TextBox3.Text))
End Sub
Output
32
Devanshu
03213702014
Front End Design Tool VB.Net
Q17: Write a program to compare three nos and print the largest number among these nos
using if statement
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
If TextBox1.Text > TextBox2.Text And TextBox1.Text > TextBox3.Text Then
MessageBox.Show("The Greatest Number among three is " & TextBox1.Text)
ElseIf TextBox2.Text > TextBox1.Text And TextBox2.Text > TextBox3.Text Then
MessageBox.Show("The Greatest Number among three is " & TextBox2.Text)
ElseIf TextBox3.Text > TextBox2.Text And TextBox3.Text > TextBox1.Text Then
MessageBox.Show("The Greatest Number among three is " & TextBox3.Text)
ElseIf TextBox1.Text = TextBox2.Text And TextBox1.Text = TextBox3.Text Then
MessageBox.Show("All Number are same ")
ElseIf TextBox1.Text = TextBox2.Text Or TextBox2.Text = TextBox3.Text Or TextBox1.Text = TextBox3.Text
Then
MessageBox.Show("Two Number is Same")
End If
End Sub
33
Devanshu
03213702014
Front End Design Tool VB.Net
Output
34
Devanshu
03213702014
Front End Design Tool VB.Net
Q18: Write a program to find out whether a number is prime or not using if statement.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number", "Enter a Number")
Dim t As Integer
For i = 2 To (n - 1)
If n Mod i = 0 Then
t = 11
End If
Next
If t = 11 Then
MessageBox.Show("It is Not Prime", "Prime or Not")
Else
MessageBox.Show("It is Prime")
End If
End Sub
35
Devanshu
03213702014
Front End Design Tool VB.Net
Output
36
Devanshu
03213702014
Front End Design Tool VB.Net
Q19: Write a program to print all the Even and Odd numbers between the range given by the
user using if statement.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number", "Enter a Number")
Dim t As String = ""
Dim t1 As String = ""
For i = 2 To n Step 2
t=t&i&","
Next
For i = 1 To n Step 2
t1 = t1 & i & " , "
Next
t = t.Remove(t.Length - 2)
t1 = t1.Remove(t1.Length - 2)
MessageBox.Show("Even Numbers Are : " & t)
MessageBox.Show("Odds Numbers Are : " & t1)
37
Devanshu
03213702014
Front End Design Tool VB.Net
End Sub
Output
38
Devanshu
03213702014
Front End Design Tool VB.Net
Q20: Write a program to display the grade obtained by the child according to the marks obtained
by him/her using select case. Criteria for assigning the grades is given below :
If marks are
>=90 - Grade is A
<90 and >=80 Grade is B
<80 and >=70 Grade is C
<70 and >=60 Grade is D
<60 Grade is E
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Double = InputBox("Enter your Marks", "Marks")
Select Case n
Case >= 90
MessageBox.Show("Grade of the Student is A")
Case Is < 90 And n >= 80
MessageBox.Show("Grade of the Student is B")
39
Devanshu
03213702014
Front End Design Tool VB.Net
Output
40
Devanshu
03213702014
Front End Design Tool VB.Net
Q21: Write a program to print table of number given by the user using for.. next.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number ", "Enter a Number")
Dim t As String = ""
For i = 1 To 10
t = t & n & " * " & i & " = " & n * i & vbCrLf
Next
MessageBox.Show(t)
End Sub
41
Devanshu
03213702014
Front End Design Tool VB.Net
Output
42
Devanshu
03213702014
Front End Design Tool VB.Net
Q22: Write a program to print the Fibonacci series with in a given range using for.. next.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a NUmber", "Enter A Number")
Dim t As String = ""
Dim n1 As Integer = 0
Dim n2 As Integer = 1
Dim n3 As Integer = 0
For i = 1 To n
t = t & n1 & " , "
n1 = n2 + n3
n2 = n3
43
Devanshu
03213702014
Front End Design Tool VB.Net
n3 = n1
Next
t = t.Remove(t.Length - 2)
MessageBox.Show(t)
End Sub
Output
44
Devanshu
03213702014
Front End Design Tool VB.Net
Design
45
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number", "Enter a Number")
Dim t As String = ""
Select Case n
Case 1
For i = 1 To 15 Step 2
t=t&i&","
Next
t = t.Remove(t.Length - 2)
MessageBox.Show(t)
Case 2
For i = 0.2 To 2.0 Step 0.2
t=t&i&","
Next
t = t.Remove(t.Length - 2)
MessageBox.Show(t)
Case 3
For i = 15 To 1 Step -2
t=t&i&","
Next
t = t.Remove(t.Length - 2)
MessageBox.Show(t)
Case 4
For i = 10 To -15 Step -5
t=t&i&","
Next
t = t.Remove(t.Length - 2)
MessageBox.Show(t)
End Select
End Sub
46
Devanshu
03213702014
Front End Design Tool VB.Net
Output
47
Devanshu
03213702014
Front End Design Tool VB.Net
48
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim r As Integer = CInt(TextBox1.Text)
Dim i, j As Integer
Dim str As String = ""
i=1
While (i <= r)
j=1
While (j <= ((r - i)))
str = str & " "
j=j+1
End While
j=1
While (j <= (i * 2 - 1))
str = str & "*"
j=j+1
End While
str = str & " " & vbCrLf
i=i+1
End While
MessageBox.Show(str)
End Sub
End Class
Output
49
Devanshu
03213702014
Front End Design Tool VB.Net
2. A
AB
AB C
AB C D
Design
50
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim t As String = ""
Dim t1 As String = ""
Dim t2 As String = ""
Dim t3 As String = ""
For i = 4 To 0 Step -1
t=t&""
Next
For j = 3 To 0 Step -1
t1 = t1 & " "
Next
For j = 2 To 0 Step -1
t2 = t2 & " "
Next
For j = 1 To 0 Step -1
t3 = t3 & " "
Next
MessageBox.Show(t & "A" & vbCrLf & t1 & "AB" & vbCrLf & t2 & "ABC" & vbCrLf & t3 & "ABCD")
End Sub
Output
51
Devanshu
03213702014
Front End Design Tool VB.Net
Q25: Create an Application to set Text Background Color Fore Color ,Font and Height properties
of a Textbox using With Statement.
Design
52
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
With TextBox1
.BackColor = Color.Cyan
.ForeColor = Color.Gray
.Font = New Font("Times New Roman", 22, FontStyle.Bold)
End With
End Sub
Output
53
Devanshu
03213702014
Front End Design Tool VB.Net
54
Devanshu
03213702014
Front End Design Tool VB.Net
Q26: Using For_ Each_ Next Loop change the fore color of all the labels in a form.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim lb As Control
For Each lb In Controls
If TypeOf lb Is Label Then
lb.ForeColor = Color.Green
End If
Next
End Sub
55
Devanshu
03213702014
Front End Design Tool VB.Net
Output
56
Devanshu
03213702014
Front End Design Tool VB.Net
Q27: Write a program to check whether an entered number is Armstrong or not using do
while..loop.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number", "Enter a Number")
Dim t As Integer
Dim t1 As Integer
Dim t2 As Integer = 0
t=n
Do While (t <> 0)
t1 = t Mod 10
t = t \ 10
t2 = t2 + Math.Pow(t1, 3)
Loop
If t2 = n Then
MessageBox.Show("The Number is Armstrong")
Else
MessageBox.Show("The Number is not Armstrong")
End If
End Sub
57
Devanshu
03213702014
Front End Design Tool VB.Net
Output
58
Devanshu
03213702014
Front End Design Tool VB.Net
Q28: Write a program to check whether an entered string is Palindrome or not using do
while..loop.
Design
Coding
Public Class Form1
st = InputBox(",")
a = Len(st)
While (a >= 1)
s = s & Mid(st, a, 1)
a=a-1
End While
If st = "" Then
MessageBox.Show("Enter a String")
ElseIf st = s Then
MessageBox.Show(st & " Is Palindrome")
59
Devanshu
03213702014
Front End Design Tool VB.Net
Else
MessageBox.Show(st & " Is Not Palindrome")
End If
End Sub
End Class
Output
60
Devanshu
03213702014
Front End Design Tool VB.Net
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n As Integer = InputBox("Enter a Number", "Enter a Number")
Dim t As Integer = n - 1
Dim t1 As Integer = n
Do Until (t = 1)
n=n*t
t=t-1
Loop
MessageBox.Show("Factorial of the Number " & t1 & " is " & n)
End Sub
61
Devanshu
03213702014
Front End Design Tool VB.Net
Output
62
Devanshu
03213702014
Front End Design Tool VB.Net
Q30: Create an Array with 10 elements as entered by the user and search the number asked by
the user and display its position.
Design
Coding
Dim a(9) As Integer
03213702014
Front End Design Tool VB.Net
Dim t1 As Integer = 0
Dim t2 As Integer
For Each item In a
t1 = t1 + 1
If item = n Then
t2 = 10
Exit For
End If
Next
If t2 = 10 Then
MessageBox.Show("The Position of Number " & n & " is " & t1)
Else
MessageBox.Show("The Number " & n & " is not in Array")
End If
End Sub
Output
64
Devanshu
03213702014
Front End Design Tool VB.Net
Design
Coding
Dim a(5) As Integer
Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim t As String = ""
For i = 0 To 5
a(i) = InputBox("Enter the Number of Array", "Enter the Number")
t = t & a(i) & " , "
Next
t = t.Remove(t.Length - 2)
Label2.Text = "Array : " & t
End Sub
03213702014
Front End Design Tool VB.Net
Output
66
Devanshu
03213702014
Front End Design Tool VB.Net
Q32: Create a Menu driven application to show Matrix Addition, Subtraction and Multiplication.
Also give the user the option to exit from the application.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim m1(0 To 2, 0 To 2) As Integer
Dim m2(0 To 2, 0 To 2) As Integer
Dim m3(0 To 2, 0 To 2) As Integer
Dim n As Integer = TextBox1.Text
Dim stra As String = ""
Dim stra1 As String = ""
Dim stra2 As String = ""
67
Devanshu
03213702014
Front End Design Tool VB.Net
For i = 0 To 2
For j = 0 To 2
m1(i, j) = InputBox("Enter Element No : 1", "First Matrix")
stra = stra & m1(i, j) & " "
Next
stra = stra & vbCrLf
Next
For i = 0 To 2
For j = 0 To 2
m2(i, j) = InputBox("Enter Element No : 1", "Second Matrix")
stra1 = stra1 & m2(i, j) & " "
Next
stra1 = stra1 & vbCrLf
Next
MessageBox.Show(stra, "First Matrix")
MessageBox.Show(stra1, "Second Matrix")
Select Case n
Case 1
For i = 0 To 2
For j = 0 To 2
m3(i, j) = m1(i, j) + m2(i, j)
stra2 = stra2 & m3(i, j) & " "
Next
stra2 = stra2 & vbCrLf
Next
MessageBox.Show(stra2, "Sum of Matrix ")
Case 2
For i = 0 To 2
For j = 0 To 2
m3(i, j) = m1(i, j) - m2(i, j)
stra2 = stra2 & m3(i, j) & " "
Next
stra2 = stra2 & vbCrLf
Next
MessageBox.Show(stra2, "Subtraction of Matrix ")
Case 3
For i = 0 To 2
For j = 0 To 2
m3(i, j) = 0
For k = 0 To 2
m3(i, j) = m3(i, j) + m1(i, k) * m2(k, j)
Next
stra2 = stra2 & m3(i, j) & " "
Next
stra2 = stra2 & vbCrLf
Next
MessageBox.Show(stra2, "Product of Matrix ")
End Select
End Sub
68
Devanshu
03213702014
Front End Design Tool VB.Net
Output
69
Devanshu
03213702014
Front End Design Tool VB.Net
Design
Coding
70
Devanshu
03213702014
Front End Design Tool VB.Net
71
Devanshu
03213702014
Front End Design Tool VB.Net
Q34: Create a jagged Array with 3 rows and initializes each row with the elements print in the
window.
Design
72
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Public Class Form2
For j = 0 To innerarray.Length - 1
str = str & innerarray(j)
Next
str = str & vbCrLf
Next
Label1.Text = str
End Sub
End Class
Output
73
Devanshu
03213702014
Front End Design Tool VB.Net
Q35: Write a program to create simple array list and perform various operations of array list.
Design
74
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim al As New ArrayList
Dim str As String = ""
Dim c As Integer = TextBox1.Text
Dim t1 As Integer
Dim t2 As Integer
Dim t3 As Integer
Dim t4 As Integer
al.Add(5)
al.Add(8)
al.Add(9)
Select Case c
Case 1
t1 = InputBox("Enter a Number to Add", "Enter a Number")
al.Add(t1)
For Each item In al
str = str & item & " , "
Next
str = str.Remove(str.Length - 2)
MessageBox.Show(str, "Array")
Case 2
t2 = InputBox("Enter a Number to Add", "Enter a Number")
t3 = InputBox("Enter the position from which the Element is to Changed", "Enter the Number")
al.Insert(t3 - 1, t2)
For Each item In al
str = str & item & " , "
Next
str = str.Remove(str.Length - 2)
MessageBox.Show(str, "Array")
Case 3
t4 = InputBox("Enter the position from which the Element is to Deleted", "Enter the Number")
75
Devanshu
03213702014
Front End Design Tool VB.Net
al.RemoveAt(t4 - 1)
For Each item In al
str = str & item & " , "
Next
str = str.Remove(str.Length - 2)
MessageBox.Show(str, "Array")
Case 4
al.Sort()
For Each item In al
str = str & item & " , "
Next
str = str.Remove(str.Length - 2)
MessageBox.Show(str, "Array")
End Select
Output
Q36: Create a structure for storing book details and populate it with data.
76
Devanshu
03213702014
Front End Design Tool VB.Net
Design
Coding
Structure bd
Dim id As Integer
Dim bn As String
Dim an As String
End Structure
Output
77
Devanshu
03213702014
Front End Design Tool VB.Net
78
Devanshu
03213702014
Front End Design Tool VB.Net
Q37: Create an enumeration named Designation & takes 5 Designations in it -: Manager, Asst
Manager, Project Manager, Team Lead and Developer. Initialize salaries for these posts in the
enumerator & display it in TextBox.
Design
Coding
Public Class Form3
Enum salary
manager = 230000
ceo = 1000000
ast_manager = 150000
Project_manager = 200000
developer = 700000
team_lead = 900000
End Enum
03213702014
Front End Design Tool VB.Net
End If
End Sub
End Class
Output
80
Devanshu
03213702014
Front End Design Tool VB.Net
Coding
Public Class Form4
03213702014
Front End Design Tool VB.Net
End Class
Output
82
Devanshu
03213702014
Front End Design Tool VB.Net
Q39: To find the Fibonacci series with in a given range with the help of procedure.
Design
Coding
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim f = CInt(TextBox1.Text)
Dim l = CInt(TextBox2.Text)
Dim t = 0
Dim t1 = 0
Dim t2 = 1
Dim str = ""
For i = f To l
t = f + t2
f = t2
t2 = t
If t2 > l Then
Exit For
End If
str = str & t & " , "
Next
str = str.Remove(str.Length - 2)
MessageBox.Show(str, "Fibonnaci Series")
83
Devanshu
03213702014
Front End Design Tool VB.Net
End Sub
Output
84
Devanshu
03213702014
Front End Design Tool VB.Net
Q40: Write a program to differentiate between parameter passing (ByVal and ByRef).
Design
Coding
Function sw(ByRef t1 As Integer, ByRef t2 As Integer) As Integer
Dim t3 As Integer
Dim str As String = ""
t3 = t1
t1 = t2
t2 = t3
str = str & "First Number = " & t1 & vbCrLf & "Second Number = " & t2
Return Nothing
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MessageBox.Show("First Number = " & TextBox1.Text & vbCrLf & "Second Number = " & TextBox2.Text,
"ByVal")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim t As String
t = sw(CInt(TextBox1.Text), CInt(TextBox2.Text))
85
Devanshu
03213702014
Front End Design Tool VB.Net
MessageBox.Show(t, "ByRef")
End Sub
Output
86
Devanshu
03213702014
Front End Design Tool VB.Net
87
Devanshu
03213702014