将Quick BASIC转换为VB.Net - 随机访问文件 [英] Converting Quick BASIC to VB.Net - Random Access Files
本文介绍了将Quick BASIC转换为VB.Net - 随机访问文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在VB.Net中执行以下操作?
< pre $
OPENtest.datFOR RANDOM AS#1 LEN = 20
FIELD#1,10 AS $,10 AS b $
LSET a $ = One
LSET b $ =Two
PUT#1,1
GET#1,1
PRINT a $,b $
CLOSE#1
解决方案
, FilePut 和 FileGet 语句应该是上面大部分代码的直接替换。
Microsoft.VisualBasic.FileOpen(1,test.dat,OpenMode.Random,OpenAccess.ReadWrite,OpenSh are.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 =& A& ; B =& input.B)
FileClose(1)
I'm trying to convert an old Quick BASIC program to VB.Net. There doesn't appear to be any direct replacement for the old file statements. Building a database seems like overkill for my simple needs.
How can I do the following in 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
解决方案
The Microsoft.VisualBasic.FileOpen, FilePut, and FileGet statements should be pretty direct replacements for most of your code above.
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)
这篇关于将Quick BASIC转换为VB.Net - 随机访问文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文