Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
FOR
PROGRAMMING IN VISUAL BASIC
TOTAL = 0
For i = 0 To 4
List3.AddItem (MARKS(i))
Next
Text3.Text = TOTAL
Text4.Text = TOTAL / 5
End Sub
OUTPUT:-
2.DESIGN A USER INTERFACE THAT CALCULATE THE SIMPLE INTEREST.
Private Sub Command1_Click()
Dim R As Double
Dim P As Double
Dim T As Double
R=8
If IsNumeric(Text1.Text) Then
P = Val(Text1.Text)
Else
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
If IsNumeric(Text2.Text) Then
T = Val(Text2.Text)
Else
Text2.Text = ""
Text2.SetFocus
Exit Sub
End If
Text4.Text = (R * P * T) \ 100
End Sub
Dim R As Double
Dim P As Double
Dim T As Double
R=8
If IsNumeric(Text1.Text) Then
P = Val(Text1.Text)
Else
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
If IsNumeric(Text2.Text) Then
T = Val(Text2.Text)
Else
Text2.Text = ""
Text2.SetFocus
Exit Sub
End If
Text4.Text = (R * P * T) \ 100
INTEREST = Val(Text4.Text)
Text5.Text = P + INTEREST
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
OUTPUT:-
3.Design a user interface to search a no. from given
list by binary search.
flag = 0
For i = 0 To n
List1.AddItem (a(i))
Next
For i = 0 To n
For j = 0 To n
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Next j
Next i
For i = 0 To n
List2.AddItem (a(i))
Next
Text1.Text = num
low = 0
high = n
high = mid - 1
Else
low = mid + 1
Else
flag = 1
End If
End If
End If
Wend
If flag = 1 Then
Else
End If
End Sub
Output:-
4.Design a user interface to search a no. from given
list by linear search.
Private Sub Command5_Click()
For i = 0 To NUM
List1.AddItem (a(i))
Next
Text1.Text = b
For i = 0 To NUM
If a(i) = b Then
flag = 1
Exit For
End If
Next
If flag = 1 Then
Else
End If
End Sub
Output:-
5.Design a user interface to sort the given list by
bubble sort.
Private Sub Command7_Click()
List1.Clear
For i = 0 To n
List1.AddItem (a(i))
Next
For i = n To 0 Step -1
For j = 1 To i
temp = a(j - 1)
a(j - 1) = a(j)
a(j) = temp
End If
Next j
Next i
List2.Clear
For i = 0 To n
MsgBox (a(i))
List2.AddItem (a(i))
Next
End Sub
Output:-
6.Design a user interface to sort the given list by
selection sort.
Private Sub Command7_Click()
List1.Clear
For i = 0 To n
List1.AddItem (a(i))
Next
For i = 0 To n
For j = 0 To n
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Next j
Next i
List2.Clear
For i = 0 To n
MsgBox (a(i))
List2.AddItem (a(i))
Next
Output:-
7.Design a user interface to find the maximum and
minimum no. from the list.
Private Sub Command3_Click()
List1.Clear
For I = 0 To NUM
List1.AddItem (a(I))
Next
max = a(0)
min = a(0)
For I = 0 To NUM
max = a(I)
End If
min = a(I)
End If
Next
Text1.Text = max
Text2.Text = min
End Sub
Output:-
8.design a user interface with 5 label and 5 button for
fontsize,colour,visible.
Private Sub Command1_Click()
Label1.BackColor = vbRed
Label2.BackColor = vbRed
Label3.BackColor = vbRed
Label4.BackColor = vbRed
Label5.BackColor = vbRed
End Sub
Label1.BackColor = vbBlue
Label2.BackColor = vbBlue
Label3.BackColor = vbBlue
Label4.BackColor = vbBlue
Label5.BackColor = vbBlue
End Sub
Label1.BackColor = vbGreen
Label2.BackColor = vbGreen
Label3.BackColor = vbGreen
Label4.BackColor = vbGreen
Label5.BackColor = vbGreen
End Sub
Label1.FontSize = b
Label2.FontSize = b
Label3.FontSize = b
Label4.FontSize = b
Label5.FontSize = b
End Sub
Label1.Visible = a
Label2.Visible = a
Label3.Visible = a
Label4.Visible = a
Label5.Visible = a
End Sub
Output:-