Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
VB.NET General Discussion
StreamReader question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="tibby812" data-source="post: 7948" data-attributes="member: 2906"><p>Good Evening,</p><p></p><p>I have just signed up in hopes of finding a good explanation to my question. I would like to thank everyone in advance for any help they could give.</p><p></p><p>Problem:</p><p></p><p>I am trying to create a "Previous Record" button for a windows form.</p><p></p><p>Current Setup:</p><p></p><p>i have a File menu with 2 menu items ( OPEN , EXIT )</p><p>i have 2 labels for display purposes ( nameLabel , phoneLabel )</p><p>and i have 2 buttons ( NEXT , PREV )</p><p></p><p>i am using the StreamReader to open up and read from a txt file.</p><p></p><p>Here is the code that i have on the form.</p><p></p><p>[CODE]</p><p>Option Strict On</p><p></p><p>Imports System.IO</p><p></p><p>Public Class Form1</p><p> Inherits System.Windows.Forms.Form</p><p></p><p>Private phoneStreamReader As StreamReader</p><p></p><p> Private Sub fileOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fileOpenMenuItem.Click</p><p> 'Open the file</p><p> Dim response As DialogResult</p><p> OpenFileDialog1.InitialDirectory = Application.StartupPath</p><p> response = OpenFileDialog1.ShowDialog()</p><p> If response <> DialogResult.Cancel Then</p><p> phoneStreamReader = New StreamReader(OpenFileDialog1.FileName)</p><p> nextButton_Click(sender, e)</p><p> End If</p><p></p><p> End Sub</p><p></p><p> Private Sub nextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextButton.Click</p><p> Dim test As Long</p><p> If phoneStreamReader.Peek <> -1 Then</p><p> nameLabel.Text = phoneStreamReader.ReadLine()</p><p> phoneLabel.Text = phoneStreamReader.ReadLine()</p><p> End If</p><p> End Sub</p><p></p><p> Private Sub prevButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles prevButton.Click</p><p> </p><p> End Sub</p><p>End Class</p><p></p><p></p><p>[/CODE] </p><p></p><p>As the code shows, i am asking the user to specify the TXT file, then the file is open and read. The first 2 lines are then assigned to the Labels.Text</p><p></p><p>My problem is i would like to setup a previous button to go "backwards" in the txt file.</p><p></p><p>Is this possible?</p><p></p><p>Thank You</p><p></p><p>Tibby</p></blockquote><p></p>
[QUOTE="tibby812, post: 7948, member: 2906"] Good Evening, I have just signed up in hopes of finding a good explanation to my question. I would like to thank everyone in advance for any help they could give. Problem: I am trying to create a "Previous Record" button for a windows form. Current Setup: i have a File menu with 2 menu items ( OPEN , EXIT ) i have 2 labels for display purposes ( nameLabel , phoneLabel ) and i have 2 buttons ( NEXT , PREV ) i am using the StreamReader to open up and read from a txt file. Here is the code that i have on the form. [CODE] Option Strict On Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form Private phoneStreamReader As StreamReader Private Sub fileOpenMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fileOpenMenuItem.Click 'Open the file Dim response As DialogResult OpenFileDialog1.InitialDirectory = Application.StartupPath response = OpenFileDialog1.ShowDialog() If response <> DialogResult.Cancel Then phoneStreamReader = New StreamReader(OpenFileDialog1.FileName) nextButton_Click(sender, e) End If End Sub Private Sub nextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextButton.Click Dim test As Long If phoneStreamReader.Peek <> -1 Then nameLabel.Text = phoneStreamReader.ReadLine() phoneLabel.Text = phoneStreamReader.ReadLine() End If End Sub Private Sub prevButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles prevButton.Click End Sub End Class [/CODE] As the code shows, i am asking the user to specify the TXT file, then the file is open and read. The first 2 lines are then assigned to the Labels.Text My problem is i would like to setup a previous button to go "backwards" in the txt file. Is this possible? Thank You Tibby [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
VB.NET General Discussion
StreamReader question
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom