3

我正在尝试将旧的 Quick BASIC 程序转换为 VB.Net。似乎没有任何直接替代旧文件语句的方法。对于我的简单需求,构建数据库似乎有点过头了。

如何在 VB.Net 中执行以下操作?

OPEN "test.dat" FOR RANDOM AS #1 LEN = 20
FIELD #1, 10 AS a$, 10 AS b$
LSET a$ = "One"
LSET b$ = "Two"
PUT #1, 1
GET #1, 1
PRINT a$, b$
CLOSE #1
4

1 回答 1

7

Microsoft.VisualBasic.FileOpen、FilePut 和FileGet语句应该是上面大部分代码的直接替代品

    Microsoft.VisualBasic.FileOpen(1, "test.dat", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared)

    Dim output As New Fields

    output.A = "One"
    output.B = "Two"

    Microsoft.VisualBasic.FilePut(1, output, 1)

    Dim input As New Fields

    Microsoft.VisualBasic.FileGet(1, input, 1)

    Debug.WriteLine("A = " & input.A & "; B = " & input.B)

    FileClose(1)
于 2012-01-16T21:27:02.293 回答