文本文件“打印”从 VB6 开始在 VB.NET 中

发布于 2024-12-13 02:15:54 字数 427 浏览 3 评论 0原文

我正在将应用程序从 VB6 移植到 VB.NET,但遇到了 VB.NET 不喜欢的情况。 “Print #”功能(无论其真实名称是什么)。代码如下:

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

我只是想知道 VB.NET 中的等价物是什么,因为有很多这样的东西,我不想在这里直到时间结束。 谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花开半夏魅人心 2024-12-20 02:15:54

使用 WriteWriteLine 方法写入文件...

一些基本示例此处此处

Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.WriteLine(TextBox1.Text)
...
objWriter.Close()

Use Write or WriteLine method for writing a file...

Some basic examples Here and Here

Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.WriteLine(TextBox1.Text)
...
objWriter.Close()
神妖 2024-12-20 02:15:54

您应该使用 StreamWriter 类:

Using writer = File.CreateText(path)
    writer.WriteLine(...)
End Using

You should use the StreamWriter class instead:

Using writer = File.CreateText(path)
    writer.WriteLine(...)
End Using
橘寄 2024-12-20 02:15:54

不如使用微软提供的功能,而不是胡编乱造。

打印、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-我们/库/kaf4ssya(v=VS.90).aspx

How about using the functions provided by Microsoft instead of making stuff up.

Print, PrintLine Functions
Writes display-formatted data to a sequential file.
http://msdn.microsoft.com/en-us/library/9cksc646(v=VS.90).aspx


Programming Element Support Changes Summary

Support for various programming elements has changed since Visual Basic 6.0, mostly for interoperability with the common language runtime. Many Visual Basic 6.0 elements are renamed, reclassified, or combined with other programming elements. Several elements are no longer supported, because the common language runtime (CLR) includes functionality that makes them unnecessary. For more information, see Common Language Runtime.

For additional information about changes to Visual Basic, see Help for Visual Basic 6.0 Users. This topic includes information about changes to the integrated development environment (IDE), Web functionality, projects, forms, constants, and the Circle, Line, and Pset methods.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文