Solved

Buttons- Return to beginning and End of a Text File

Posted on 2007-12-03
2
141 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

713 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