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

use*_*657 3 vb.net file random-access qbasic

我正在尝试将旧的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
Run Code Online (Sandbox Code Playgroud)

com*_*ech 7

Microsoft.VisualBasic.FileOpen,FilePutFileGet语句应该是上面的大部分代码十分直接的替代品.

    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)
Run Code Online (Sandbox Code Playgroud)