Visual Basic 6.0
Slip29
Q.1) Write a VB Program to design following screen which contain static value for size,
As per selection bill will be displayed.
[Marks 15]
Solution
Dim A As Integer
Dim B As Integer
Dim C As Integer
Private Sub Command1_Click()
If Option1.Value = True Then
A = 150
B = 220
C = 300
If Option3.Value = True Then
Text1.Text = A
ElseIf Option4.Value = True Then
Text1.Text = B
ElseIf Option5.Value = True Then
Text1.Text = C
End If
End If
If Option2.Value = True Then
A = 200
B = 280
C = 350
If Option3.Value = True Then
Text1.Text = A
ElseIf Option4.Value = True Then
Text1.Text = B
ElseIf Option5.Value = True Then
Text1.Text = C
End If
End If
End Sub
Output
Q.2) Write a VB program for dragging and dropping multiple objects. (Take two command
buttons RESET and EXIT, and four image controls). When user click on reset button
then all images will go to original position. [Marks 25]
Solution
Private Sub Command1_Click()
For i = 1 To 4
Image1(i).Visible = True
Next
End Sub
Private Sub Command1_DragDrop(Source As Control, X As Single, Y As Single)
BadDrop Source
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command2_DragDrop(Source As Control, X As Single, Y As Single)
BadDrop Source
End Sub
Private Sub Command2_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Source.Visible = False
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Dim i As Integer
For i = 1 To 4
Image1(i).DragIcon = Image1(i).Picture
Next
End Sub
Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Source.Visible = False
End Sub
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.Picture = Source.Picture
End Sub
Private Sub BadDrop(Source)
Source.Visible = True
End Sub
Tags:
VB 6.0