将Quick BASIC转换为VB.Net-随机访问文件



我正在尝试将一个旧的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

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)

最新更新