Question

Please write a short code that opens a text file called "data.txt" and reads, writes, and...

Please write a short code that opens a text file called "data.txt" and reads, writes, and keeps writing data to the file in vb.net.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

' read/open file

Dim variable_name As String

variable_name = My.Computer.FileSystem.ReadAllText("location\data.txt")

OR

' open and read file line by line

Dim file_name, read_line As String

file_name = "location\data.txt"

If System.IO.File.Exits(file_name) = True Then

Dim objReader As New

System.IO.StreamReader(file_name)

Do While objReader.Peek <> -1

read_file = read_file & objReader.ReadLine() & vbNewLine

Loop

TextBox1.text = read_line

Else

MessageBox.Show("file is not available")

End If

' Write file

Dim file_name As String

file_name = "location\data.txt"

If System.IO.File.Exits(file_name) = True Then

Dim objWriter as New

System.IO.StreamWriter(file_name)

objWriter.Write(TextBox1.text)

obj.Writer.Close()

MessageBox.Show("write text here into file")

Else

MessageBox.Show("file is not available")

End If

Add a comment
Know the answer?
Add Answer to:
Please write a short code that opens a text file called "data.txt" and reads, writes, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a code that reads a line of text from standard in, and writes it to...

    Write a code that reads a line of text from standard in, and writes it to a file called "output.txt" in C please

  • JAVA Write a program that 1. opens a text file 2. reads lines of text from...

    JAVA Write a program that 1. opens a text file 2. reads lines of text from the file 3. Converts each line to uppercase 4. saves them in an ArrayList 5. Writes the list of Strings to a new file named "CAPSTEXT.txt" Mainjavo ext.txt Instructions from your teacher 1 My mistress' eyes are nothing like the sun; 2 Coral is far more red than her lips' red; 3 If snow be white, why then her breasts are dun; 4 If...

  • QUESTION The ReadFile class opens and reads a text file. The WriteFile class opens and writes...

    QUESTION The ReadFile class opens and reads a text file. The WriteFile class opens and writes to a file. Compile and run these programs. There are several ways to read/write text files. The examples shown here are just one way of achieving this. Look at the API for the BufferedReader class. The readline() method is a simple way to read the text file line by line. It returns null when the end of the file has been reached. https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html Look...

  • Write a program that opens a text file called input.txt and reads its contents into a...

    Write a program that opens a text file called input.txt and reads its contents into a stack of characters. The program should then pop the characters from the stack and save them in a second text file called output.txt. The order of the characters saved in the second file should be the reverse of their order in the first file. We don’t know the text file length. Input.txt This is a file is for test output.txt tset rof si elif...

  • Draw the flowchart of the code: Write code that opens an Excel file named area.xlsx, writes...

    Draw the flowchart of the code: Write code that opens an Excel file named area.xlsx, writes 'Radius' in cell A1, writes 'Area' in cell B1, and then using the while command populates the next 10 rows of column A (A2-A11) with the numbers 1, 2, ..., 10 and the next 10 rows of column B with the circle areas that correspond to the radii on the left. A while loop should be used.

  • USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3...

    USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3 numbers, and print the sum of those numbers to the console 16. Write code that opens a file named words.txt containing an essay, and the prints out the SECOND word in the file to the console

  • Please write this code in python programming and provide a screen short of the code. Reading:...

    Please write this code in python programming and provide a screen short of the code. Reading: P4E 7; Tut 7.2, 7.2.1 Upload an original Python script that satisfies the following criteria: It has at least two functions Function 1: This function has one parameter, a string containing the path to an existing text file that will be read by your function Using a with statement, the function opens the file indicated by the parameter for reading The function counts the...

  • and save it in the same folder as your source Download file: data.txt code file. data.txt...

    and save it in the same folder as your source Download file: data.txt code file. data.txt contains a list of client's account number, client's name and their balance. Write a C program to read rows of data from the file and store them in the arrays. Display the list of client's account number, client's name and the client's balance on the screen in reverse order. The program should write the data in reverse order (without header) to another file called...

  • write a Java console application that Create a text file called Data.txt. Within the file, use...

    write a Java console application that Create a text file called Data.txt. Within the file, use the first row for the name and data title, and use the second row for column headers. Within the columns, insure that the first column is a label column and other columns contain numeric data. In your application, read file Data.txt into parallel arrays, one for each column in the file. Create method printArrays to print the header row(s) and the (unsorted) data in...

  • (statistics.py) Write a program that reads data from the file provided, data.txt, into a list. Once...

    (statistics.py) Write a program that reads data from the file provided, data.txt, into a list. Once the data are in a list, calculate and print the following: sum = 69.28 mean = 3.46 min = 0.19 max = 8.29 You may use the Python built-ins, min(), max(), and sum(). Format the numbers using '.2f'.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT