Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

I need help with editing multiple text files in Visual Basic.

lusius188lusius188 Member Posts: 31
I need help with editing multiple text files in VB. I am a newbie at this. This is my code...
Open "C:My Documents*.txt" for Output as #1
print #1,"bla bla bla"
close #1
It keeps telling me that the file isn't found. Does visual basic allow you to use wildcard characters? Any help would be greatly appreciated.
Thanx
- lusius188

Comments

  • infidelinfidel Member Posts: 2,900
    [b][red]This message was edited by the infidel at 2002-7-2 14:31:8[/red][/b][hr]
    : I need help with editing multiple text files in VB. I am a newbie at this. This is my code...
    : Open "C:My Documents*.txt" for Output as #1
    : print #1,"bla bla bla"
    : close #1
    : It keeps telling me that the file isn't found. Does visual basic allow you to use wildcard characters? Any help would be greatly appreciated.

    If you think about it, the problem should be obvious. You're effectively telling VB to open any and all files ending in ".txt" as a single file handle. If there aren't any files yet that end with ".txt" then VB would try to create the file "*.txt" which I'm sure is verboten by the OS.

    What you need to do is use either the FileSystemObject or Dir to get one file at a time to write to, or else open each one with a different handle. You could also write to a single one and just make copies of it if that would fulfill your reqs.


  • Shawn CarterShawn Carter Member Posts: 0

    _______ \ http://forcoder.org \ free video tutorials and ebooks about / Assembly JavaScript Delphi Python Go PL/SQL Java Ruby C++ C Scratch Swift PHP R Objective-C MATLAB C# Perl Visual Basic Visual Basic .NET LabVIEW Scheme Kotlin Fortran ABAP ML Dart Bash Erlang Apex Rust VBScript F# Ada FoxPro Scala Julia Crystal Lua Hack Clojure Awk Alice D COBOL SAS Transact-SQL Prolog Logo Lisp / __

Sign In or Register to comment.