Visual Basic 6.0

Visual Basic 6.0

Slip26

Q.1) Write a VB program to create menus of MS-Word and display it onto the form as
follows: [Marks 15]

Solution

Dim i, n As Integer
Private Sub Form_Activate()
n = Val(InputBox(“Enter the Number”))
For i = 1 To n
Load mnuFile(i)
mnuFile(i).Caption = InputBox(“Enter the Name For Menu”)
mnuFile(i).Visible = True
Next
End Sub

Output





Q.2) Create an application in VB to display 4 X 4 squares on the screen. One of the blocks will
be active with black color all other block will be fill with blue color. Provide a command button
as follows to move the active cell the active cell should be change only if it is within the
boundary. [25 Marks]


Solution

Private Sub cmdDown_Click()
If Text1(i).BackColor = vbDesktop And i <> 12 And Text1(i).BackColor = vbDesktop And i <> 13 And
Text1(i).BackColor = vbDesktop And i <> 14 And Text1(i).BackColor = vbDesktop And i <> 15 Then
Text1(i).BackColor = vbActiveTitleBar
Text1(i + 4).BackColor = vbDesktop
i = i + 4
Else
MsgBox ("Out of Bounds")
End If
End Sub

Private Sub cmdLeft_Click()
If Text1(i).BackColor = vbDesktop And i <> 0 And Text1(i).BackColor = vbDesktop And i <> 4 And
Text1(i).BackColor = vbDesktop And i <> 8 And Text1(i).BackColor = vbDesktop And i <> 12 Then
Text1(i).BackColor = vbActiveTitleBar
Text1(i - 1).BackColor = vbDesktop
i = i - 1
Else
MsgBox ("Out of Bounds")
End If
End Sub

Private Sub cmdRight_Click()
If Text1(i).BackColor = vbDesktop And i <> 3 And Text1(i).BackColor = vbDesktop And i <> 7 And
Text1(i).BackColor = vbDesktop And i <> 11 And Text1(i).BackColor = vbDesktop And i <> 15 Then
Text1(i).BackColor = vbActiveTitleBar
Text1(i + 1).BackColor = vbDesktop
i = i + 1
Else
MsgBox ("Out of Bounds")
End If
End Sub

Private Sub cmdUp_Click()
If Text1(i).BackColor = vbDesktop And i <> 0 And Text1(i).BackColor = vbDesktop And i <> 1 And
Text1(i).BackColor = vbDesktop And i <> 2 And Text1(i).BackColor = vbDesktop And i <> 3 Then
Text1(i).BackColor = vbActiveTitleBar
Text1(i - 4).BackColor = vbDesktop
i = i - 4
Else
MsgBox ("Out of Bounds")
End If
End Sub

Output


BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post