Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VB.NET

Status
Not open for further replies.

BDW1969

IS-IT--Management
Aug 29, 2002
43
0
0
US
I am new to VB.NET. Can anyone help. I have created a windows form attched to a database. When the form loads it show the first record, but I cant navigate off this record. Any help would be great. Here is the code I have for the navigation buttons.

Private Sub NavigationButtons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click, _
btnPrev.Click, btnNext.Click, btnLast.Click
Select Case sender.Name
Case "btnFirst"
MasterBindMgr.Position = 0
Case "btnprev"
If MasterBindMgr.Position > 0 Then
MasterBindMgr.Position -= 1
End If
Case "btnnext"
If MasterBindMgr.Position < MasterBindMgr.Count - 1 Then
MasterBindMgr.Position += 1
End If
Case "btnlast"
MasterBindMgr.Position = MasterBindMgr.Count - 1
End Select
Me.DisplayPosition()
End Sub
 
How are you defiing the set of records you want to move around in?

Bob
 
You have not named in correct case
btnnext should be btnNext
btnprev should be btnPrev
btnlast should be btnLast

in your case statements only btnFirst is correct case hence it is working


try this

Case "btnPrev"
If MasterBindMgr.Position > 0 Then
MasterBindMgr.Position -= 1
End If
Case "btnNext"
If MasterBindMgr.Position < MasterBindMgr.Count - 1 Then
MasterBindMgr.Position += 1
End If
Case "btnLast"
MasterBindMgr.Position = MasterBindMgr.Count - 1
End Select
 
To avoid this kind of situation, I usually use .ToLower with case statements. Of course, when I do global cut and pastes, I forget to change it and then have the same problem. Good Luck!

Have a great day!

j2consulting@yahoo.com
 
Thanks for the help. Works like a champ now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top