Visual Basic 6.0
Slip15
Q.3) Write a VB Program to create status bar and display it on onto the form. Status bar should have five panels to display any text, date, time, CAPS ON/OFF, Num ON/OFF.
[Marks 15]
Solution
Private Sub Form_Load()
Dim p1 As Panel
Set p1 = StatusBar1.Panels.Add(1)
p1.Text = "HELLO"
Dim p2 As Panel
Set p2 = StatusBar1.Panels.Add(2)
p2.Style = sbrDate
Dim p3 As Panel
Set p3 = StatusBar1.Panels.Add(3)
p3.Style = sbrTime
Dim p4 As Panel
Set p4 = StatusBar1.Panels.Add(4)
p4.Style = sbrCaps
Dim p5 As Panel
Set p5 = StatusBar1.Panels.Add(5)
p5.Style = sbrNum
End Sub
Output
![]() |
Status Bar |
Q.4) Write a VB program to store the details of players into the database and display that
details using ADODC. [Marks 25]
Solution
Dim c As New ADODB.Connection
Dim r As New ADODB.Recordset
Dim s As String
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
With Adodc2.Recordset
r.Close
s = "insert into PLAYER values(" & Val(Text1.Text) & ",'" & (Text2.Text) & "','" & (Text3.Text) & "')"
r.open s, c, adOpenDynamic, adLockOptimistic
s = "select * from PLAYER"
r.open s, c, adOpenDynamic, adLockOptimistic
If Not r.EOF Then
r.MoveFirst
Text1.Text = r.Fields(0).Value
Text2.Text = r.Fields(1).Value
Text3.Text = r.Fields(2).Value
End If
.Update
.Requery
End With
MsgBox "PLAYER RECORD ADDED!", vbInformation, "PLAYER"
End Sub
Private Sub Command3_Click()
r.MoveNext
If Not r.EOF Then
Text1.Text = r.Fields(0).Value
Text2.Text = r.Fields(1).Value
Text3.Text = r.Fields(2).Value
Else
MsgBox "NO MORE RECORDS!", vbInformation, "PLAYER"
End If
End Sub
Private Sub Command4_Click()
r.MovePrevious
If Not r.BOF Then
Text1.Text = r.Fields(0).Value
Text2.Text = r.Fields(1).Value
Text3.Text = r.Fields(2).Value
Else
MsgBox "NO MORE RECORDS!", vbInformation, "product"
End If
End Sub
Private Sub Form_Load()
c.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\PLAYER.MDB;Persist Security Info=False"
s = "select * from PLAYER"
r.open s, c, adOpenDynamic, adLockOptimistic
If Not r.BOF And Not r.EOF Then
r.MoveFirst
Text1.Text = r.Fields(0).Value
Text2.Text = r.Fields(1).Value
Text3.Text = r.Fields(2).Value
End If
End Sub
Output
Tags:
VB 6.0