Solved

Buttons- Return to beginning and End of a Text File

Posted on 2007-12-03
2
139 Views
Last Modified: 2010-04-30
I have a phone book program that I created in visual basic and I want a button to return to the beginning of all the entries and one button to go to the very last entry. How would I do that?

So far I have this, but I don't think it works properly
Private Sub BtnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFirst.Click
        If Index = Count Then
            Index = Index - Count + 1
            DisplayData()
        End If
    End Sub

    Private Sub BtnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLast.Click
        If Index < Count Then
            Index = Index + Count - 1
            DisplayData()
        End If
    End Sub


Thanks :)
0
Comment
Question by:ashblynn02
2 Comments
 
LVL 4

Assisted Solution

by:origfla
origfla earned 200 total points
ID: 20400349
How about:
Index=1

Index=count
0
 
LVL 25

Accepted Solution

by:
imitchie earned 300 total points
ID: 20400377
Private Sub BtnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFirst.Click
            Index = 1
            DisplayData()
    End Sub

    Private Sub BtnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLast.Click
        Index = Count
        DisplayData()
    End Sub
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fso.FolderExists("\\server\HiddenFolder$") 4 64
VB.Net Report Printing Issue 3 31
VB: Convert 2 dates to specific format 24 48
Sql server insert 13 26
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now