0

I'm porting an application from VB6 to VB.NET and have come across something that VB.NET doesn't like. The "Print #" function (whatever its real name is). The code is as follows:

Open tmp For Output As TmpNo

    'save data from first form, frminput1
    Print #TmpNo, frmInput1.txtTitle
    Print #TmpNo, frmInput1.txtStrandWidth
    Print #TmpNo, frmInput1.txtStrandThick
    'MORE IS HERE, CUT DOWN BECAUSE IT'S TOO HEFTY

Close #TmpNo

I was just wondering what the equivalent of this in VB.NET is, as there is a LOT of this and I don't want to be here until the end of time. Thanks!

4

3 回答 3

1

您应该改用StreamWriter该类:

Using writer = File.CreateText(path)
    writer.WriteLine(...)
End Using
于 2011-10-31T14:33:06.037 回答
1

写入文件的用途WriteWriteLine方法...

HereHere的一些基本示例

Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.WriteLine(TextBox1.Text)
...
objWriter.Close()
于 2011-10-31T14:33:42.497 回答
1

如何使用微软提供的功能而不是编造东西。

Print、PrintLine 函数 将显示格式的数据写入顺序文件。 http://msdn.microsoft.com/en-us/library/9cksc646(v=VS.90).aspx


编程元素支持更改摘要

自 Visual Basic 6.0 以来,对各种编程元素的支持发生了变化,主要是为了与公共语言运行时的互操作性。许多 Visual Basic 6.0 元素被重命名、重新分类或与其他编程元素组合。一些元素不再受支持,因为公共语言运行时 (CLR) 包含使它们变得不必要的功能。有关详细信息,请参阅公共语言运行时。

有关 Visual Basic 更改的其他信息,请参阅 Visual Basic 6.0 用户帮助。本主题包括有关对集成开发环境 (IDE)、Web 功能、项目、表单、常量以及 Circle、Line 和 Pset 方法的更改的信息。

http://msdn.microsoft.com/en-us/library/kaf4ssya(v=VS.90).aspx

于 2011-10-31T14:54:41.917 回答