Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8665229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:25:52+00:00 2026-06-12T17:25:52+00:00

I would like to open my .txt file, but i get this error Error

  • 0

I would like to open my .txt file, but i get this error

Error 1 ‘Open’ is not declared. File I/O functionality is normally available in the ‘Microsoft.VisualBasic’ namespace, but the targeted platform does not support it.

I’m using vb2010 and I think the code is wrong cuz it’s for vb6. How to change it to work in vb2010?

Private Sub zapisz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zapisz.Click
    Open "C:\Plik.txt" For Append As #1 'zapis
    print #1, "a" & a.Text 
    Print #1, "b" & b.Text
    Print #1, "c" & c.Text
    Print #1, "d" & d.Text
Close #1 
End Sub


Private Sub wczytaj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wczytaj.Click
    Dim strText As String, strIndex As String
Open "C:\Plik.txt" For Input As #1
    Do Until EOF(1)
        Input #1, strText
        strIndex = Left(strText, 1)
        strText = Right(strText, Len(strText) - 1)
        Select Case strIndex
            Case "a" : a = strText
            Case "b" : b = strText
            Case "c" : c = strText
            Case "d" : d = strText
        End Select
    Loop
Close #1
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:25:53+00:00Added an answer on June 12, 2026 at 5:25 pm

    The tools in the .NET framework make this sort of thing much cleaner and intuitive than the old VB6 file access statements:

    Private Sub zapisz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zapisz.Click
        Using writer As New StreamWriter("C:\Plik.txt", True)
            writer.WriteLine("a" & a.Text)
            writer.WriteLine("b" & b.Text)
            writer.WriteLine("c" & c.Text)
            writer.WriteLine("d" & d.Text)
        End Using
    End Sub
    
    Private Sub wczytaj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wczytaj.Click
        For Each line As String In File.ReadAllLines("C:\Plik.txt")
            Dim index As String = line.Substring(0, 1)
            Dim text As String = line.Substring(1)
            Select Case index
                Case "a"
                    a = text
                Case "b"
                    b = text
                Case "c"
                    c = text
                Case "d"
                    d = text
            End Select
        Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i dont have microsoft access but would like to open an mdb file, is
I would like to open 2 url's using open $url = 'http://xtreme-jumps.eu/demos.txt'; $url2 =
I would like to open an OleDbConnection to an Excel file that's in memory
I would like to open a file using open file dialog. If the opened
I have used this tutorial to make a website, but I would like that
I have the following code: (define (get-data) (define port (open-input-file ../data/problem11.txt)) (define field 0)
i have a code generator project i would like to offer like open source,
I would like to open a new aspx page when i click on a
I would like to open a document after my ASP.NET page loads in a
I would like to open up the compose page for gmail in an iframe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.