English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

5 answers

to read the file:

OPEN "some\path\to\file.txt" for Input as #1
Input #1, Varnames
Close #1

To write to the file

Open "some\path\to\file.txt" for APPEND As #2
Print #2, varnames
Close #2

This is using VB-6, since you didn't specify a version of the language.

2007-03-12 07:58:56 · answer #1 · answered by Richard H 7 · 0 0

How To Open a Text File in VB .NET (link below)

Hopefully you're using VB .NET, if not you can download and install Visual Studio 2005 Express Edition free from Microsoft and try it out.

2007-03-12 06:00:30 · answer #2 · answered by Anonymous · 0 0

Here's some simple VB text I/O statements:

open C:/FilePath/YourFileName.text for input as #1
Input #1, strInput
Close #1

Open C:/FilePath/YourFileName.text for append as #1
Write #1, StrOutput
close #1

2007-03-12 07:01:08 · answer #3 · answered by rod 6 · 0 0

you're able to do something like this: employing sr As StreamReader = GetReader(FILE_NAME); Sub GetReader(FILE_NAME as String) As StreamReader try return document.OpenText(FILE_NAME) seize ex As Exception ' pause (sleep) for a million 2d gadget.Threading.Thread.Sleep(1000) ' try returned GetReader(FILE_NAME) end try end Sub in case you choose to specify the style of tries in the past aborting particularly of going to an limitless loop, you're able to try this: Dim counter as Integer = 0; employing sr As StreamReader = GetReader(FILE_NAME); Sub GetReader(FILE_NAME as String, maxTries As Int) As StreamReader try return document.OpenText(FILE_NAME) seize ex As Exception If (counter++ == maxTries) Then return no longer something end If ' pause (sleep) for a million 2d gadget.Threading.Thread.Sleep(1000) ' try returned GetReader(FILE_NAME) end try end Sub or Sub GetReader(FILE_NAME as String, maxTries As Int) As StreamReader Dim counter as integer = 0 at the same time as (counter ++ < maxTries) try return document.OpenText(FILE_NAME) seize ex As Exception ' pause (sleep) for a million 2d gadget.Threading.Thread.Sleep(1000) end try Loop end Sub wish this might help, this would includes some errors s i've got no longer worked with VB.internet for it sluggish now (employing C#)

2016-11-24 22:33:23 · answer #4 · answered by Anonymous · 0 0

Every programming/scripting language has the basic File I/O Stuff attached. Its there in C,C++,COBOL ,FORTRAN,VB,VB Script, Java JavaScript et all.The question is where do you find them and how badly you need them.

Based on that your problem is solved. :)
Good luck.

2007-03-12 06:15:37 · answer #5 · answered by Satya 3 · 0 3

fedest.com, questions and answers