5 Replies - 615 Views - Last Post: 23 April 2015 - 05:42 PM Rate Topic: -----

#1 nnoeavil26230  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 25-March 15

Why I can open the file?

Posted 23 April 2015 - 02:19 PM

The file is save on the C drive, tem folder and file name is p
I type C:\temp\p.txt and I get an error message




Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        invfile = TextBox2.Text
        If Button1.Text = " Open" Then
            Button1.Text = "closed"
        End If

        FileOpen(1, invfile, OpenMode.Input)
        FileOpen(2, "C:\temp\o.txt", OpenMode.Output)

        FileOpen(3, "C:\temp\y.txt", OpenMode.Output)

    End Sub



    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        FileClose()
        TextBox6.Text = "file" & invfile & "is close"

    End Sub

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Button2.Text = "First" Then
            Button2.Text = "Next"
        End If
        If EOF(1) Then
            TextBox6.Text = " Eof file"
        End If
        Dim rcd As String
        Dim grade As String
        If Not EOF(1) Then
            Dim id As Integer
            Dim name1 As String
            Dim pts As Integer

            Input(1, id)
            Input(1, name1)
            Input(1, pts)
            TextBox3.Text = id
            TextBox4.Text = name1
            TextBox1.Text = pts


            Select Case pts

                Case Is > 1000
                    TextBox5.Text = "invaild"
                    rcd = id & "" & name1 & "" & pts & "" & TextBox5.Text

                    PrintLine(2, rcd)



                Case 900 To 1000
                    TextBox5.Text = "A"
                    PrintLine(3, rcd)
                Case 800 To 899
                    TextBox5.Text = "B"
                    
                    PrintLine(4, rcd)


                Case 700 To 799
                    TextBox5.Text = "C"
                    PrintLine(5, rcd)
                Case 600 To 699
                    TextBox5.Text = "D"
                    PrintLine(6, rcd)
                Case 0 To 599
                    TextBox5.Text = "F"
                    PrintLine(6, rcd)

                Case Is < 0
                    rcd = id & "" & name1 & "" & pts

                    PrintLine(2, rcd)


            End Select




        End If
    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

    End Sub
End Class

This post has been edited by modi123_1: 23 April 2015 - 02:31 PM
Reason for edit:: use the 'code' button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Why I can open the file?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13224
  • View blog
  • Posts: 52,409
  • Joined: 12-June 08

Re: Why I can open the file?

Posted 23 April 2015 - 02:21 PM

What is the error message?
Was This Post Helpful? 0
  • +
  • -

#3 nnoeavil26230  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 25-March 15

Re: Why I can open the file?

Posted 23 April 2015 - 02:28 PM

Error message I get
File is already open
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13224
  • View blog
  • Posts: 52,409
  • Joined: 12-June 08

Re: Why I can open the file?

Posted 23 April 2015 - 02:31 PM

I am guessing this is VB.NET and *NOT* VB6?
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • bin deployable
  • member icon

Reputation: 6283
  • View blog
  • Posts: 25,138
  • Joined: 12-December 12

Re: Why I can open the file?

Posted 23 April 2015 - 04:50 PM

Topic moved to VB.NET.
Was This Post Helpful? 0
  • +
  • -

#6 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1416
  • View blog
  • Posts: 3,626
  • Joined: 01-February 13

Re: Why I can open the file?

Posted 23 April 2015 - 05:42 PM

Did you click Button3 to close the files before you clicked Button1 to open them again?

Usually when this error is thrown it is because you have not closed the files before opening them again.

Just as a suggestion, you should move to the .Net StreamReader and StreamWriter classes for reading and writing from and to several files at once. The FileOpen function is an outdated method and is only kept alive for backward compatibility.

This post has been edited by IronRazer: 23 April 2015 - 05:44 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1