2012-01-16 3 views
3

VB.Net 이전 빠른 기본 프로그램을 변환하려고합니다. 이전 파일 명령문을 직접 대체하지는 않습니다. 필자의 간단한 요구에 따라 데이터베이스를 구축하는 것이 과도한 것처럼 보입니다.빠른 기본 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 

답변

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) 
+0

분야 # 1 달러 (A $) AS 10, 10 $ B AS 방법이 예제의 FIELD 문을 대체 할 수 있습니까? – Lexib0y