[單項選擇題] 設(shè)在工程中有一個標準模塊,其中定義了如下記錄類型:TyPe Record ID A3 IntegerName As String*20 End
[單項選擇題] 設(shè)在工程中有一個標準模塊,其中定義了如下記錄類型:TyPe Record ID A3 IntegerName As String*20 End TyPe 在窗體中添加一個名為Command1的命令按鈕,假設(shè)d:F1.dat文件中含有5個用戶自定義類型的記錄。要求當執(zhí)行事件過程Command1_Click時,隨機訪問該文件,并把文件中的第4條記錄讀出。下列能夠完成該操作的程序段是
A.Private Sub Command1_Click( ) Dim MyRecord As Record,PositionOpen"d:F1.dat"For Random As#1 Len=Len(My RecorPosition=4 Get#1,Position,MyrecordClose #1End Sub
B.Private Sub Command1_Click( )Dim MyRecord As Record,Position Open"d:F1.dat"For Random As #1 Len=Len(MyRecorPosition=4Put #1,Position,MyRecordClose#1 End Sub
C.Private Sub Command1_Click( )Dim MyRecord As Record,PositionOpen"d:F1.dar"For OutPut As #1 Len=Len(My RecorPosition=4Get #1,Position,MyRecordClose#1 End Sub
D.Private Sub Command1_Click( )Dim MyRecord As record,PositionOpen"d:F1.dat"For lnput As #1 Len=Len(MyRecorPosition=4Get #1,Position,MyRecordClose#1End Sub
正確答案:A
參考解析:由于是以隨機方式訪問該文件,故打開方式為Random。選項C以O(shè)utput方式打開,選項D以Input方式打開都是錯誤的。同時由于要讀出第四條記錄,故使用Get#語句。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。