I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net
I need to convert this VB6 code to .net I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
Go Back  Xtreme Visual Basic Talk > > > I need to convert this VB6 code to .net


Reply
 
Thread Tools Display Modes
  #1  
Old 05-03-2012, 10:44 AM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default I need to convert this VB6 code to .net


Code:
Open App.Path & "\test.txt" For Append As #1
Print #1, "abc"
Print #1, "def"
Print #1, "ghi"
Close #1
Reply With Quote
  #2  
Old 05-03-2012, 03:43 PM
snarfblam's Avatar
snarfblamI need to convert this VB6 code to .net snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

I suggest you do that then.
__________________
C# _VB.NET _
Reply With Quote
  #3  
Old 05-03-2012, 04:42 PM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default

It's ok I have done.

It's typical- I can't figure out how to do it so I ask for help and then I figure out how to do it myself.
Reply With Quote
  #4  
Old 05-03-2012, 04:44 PM
VisualaBasikka VisualaBasikka is offline
Centurion
 
Join Date: Oct 2004
Posts: 130
Default

Code:
        Dim FS As IO.FileStream
        FS = New IO.FileStream(Application.StartupPath() & "test.txt", IO.FileMode.Append, IO.FileAccess.Write)
        Dim SW As New IO.StreamWriter(FS)
        SW.Write("123" & vbCrLf)
        SW.Write("456" & vbCrLf)
        SW.Write("789" & vbCrLf)
        SW.Close()
        FS.Close()
Reply With Quote
  #5  
Old 05-08-2012, 09:20 AM
AtmaWeapon's Avatar
AtmaWeaponI need to convert this VB6 code to .net AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

There's a lot of ways to do file I/O. What you pieced together is good fundamentals, but here's a couple of other ways to accomplish it.

I hesitate to say this is "better" code, but it's a little more intent-revealing:
Code:
Using writer = File.AppendText("test.txt")
    writer.WriteLine("123")
    writer.WriteLine("456")
    writer.WriteLine("789")
End Using
The Using statement guarantees the file is safely closed even if an error happens. The File.AppendText() method goes to the trouble of opening all of the streams. You can see the File methods here; lots of them are convenient.

Here's an alternate way to do it without worrying about opening and closing the file yourself:
Code:
Dim lines = {"123", "456", "789"}
File.AppendAllLines("test.txt", lines)
AppendAllLines() takes an enumeration of strings and appends each as a new line to a file.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
 
I need to convert this VB6 code to .net
I need to convert this VB6 code to .net
 
-->