Return to Snippet

Revision: 55665
at February 16, 2012 07:45 by alexishawn


Initial Code
OpenFileDialog:
    'will return the absolute path of the file to upload
    FileToRead = Application.GetOpenFilename(, , "Find File", , False)
    
    If Not ((FileToRead = "False") Or (FileToRead = "")) Then
    
        '================ On first loop through file, check water controls ===================

        Open FileToRead For Input As #1
            Do While Not EOF(1)
            
ReadALine:
            Line Input #1, LineRead
            
            If LineRead = "" Then
                GoTo ReadALine
            Else
                'Put in stuff to do to the line of data here
            End If
     
            Loop
     	
        close #1
       'This happens if the user presses Cancel when they are trying to open a file to read
    Else
        ans = MsgBox("You must select a file to read for the program to continue." & VbCrLf & VbCrLf & _
            "Please select a file an try again.", vbOKCancel + vbInformation, "No File Selected")
        If ans = vbCancel Then
            MsgBox "The program is stopped."
            Exit Sub
        Else
            GoTo OpenFileDialog
        End If
        
    End If     

Initial URL

                                

Initial Description

                                

Initial Title
Open and Read File

Initial Tags

                                

Initial Language
Visual Basic