visual studio 2008 (VB)

Posted by Ousman on Stack Overflow See other posts from Stack Overflow or by Ousman
Published on 2010-06-11T08:48:04Z Indexed on 2010/06/11 8:52 UTC
Read the original article Hit count: 238

Filed under:
|

hello guys, Am writing a programming with visual basic 2008 and i want the programme to be able to read and loop through a text file line by line and showing the event of the loop on a textbox or label until a button is press and the loop will stop on any number that happend to be at the loop event and when a button is press again the loop will continue from where it starts. this is my codes below and having problem with it and any help will be really great. tanks

==========================my codes======================= Imports System.IO '==========================================================================================

Public Class Form1 '======================================================================================

'Dim nFileNum As Integer = FreeFile() ' Get a free file number
Dim strFileName As String = "C:\scb.txt"
Dim objFilename As FileStream = New FileStream(strFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim objFileRead As StreamReader = New StreamReader(objFilename)
'Dim lLineCount As Long
'Dim sNextLine As String

'======================================================================================


'========================================================================================
Private Sub btStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btStart.Click

    Try
        If objFileRead.ReadLine = Nothing Then

            MsgBox("No Accounts Available to show!", MsgBoxStyle.Information, MsgBoxStyle.DefaultButton2 = MsgBoxStyle.OkOnly)
            Return
        Else

            Do While (objFileRead.Peek() > -1)

            Loop
            lblAccounts.Text = objFileRead.ReadLine()

            'objFileRead.Close()
            'objFilename.Close()
        End If

    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        'objFileRead.Close()
        'objFilename.Close()
    End Try


End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

End Class

© Stack Overflow or respective owner

Related posts about visual-studio-2008

Related posts about vb