


當用戶選擇好一個答案并單擊“下一題目后”可以做下一個題目。當做完最后一個題目時彈出對話框提示用戶已經做完所有的練習。把用戶的所有答案以及得分記錄下來并保存到一個文本檔案中。檔案名自定。為了簡單,只考慮一篇文章,有10個選擇題,每個題目10分。基本框架如圖,求完善····TAT 不會做啊····
uj5u.com熱心網友回復:
定義 2 個表單級的陣列變數Dim Choice(9) As String, Points As Integer
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Button3_Click(......)
Dim tmp As String
For j = 1 To 4
If Me.Controls.Item(j - 1).Value = True Then
tmp = Chr(64 + j)
Choice(i) = tmp
If tmp = a(i, 5) Then Points = Points + 10
Exit For
End If
Next j
If j = 5 Then
MsgBox("請選擇答案")
Exit Sub
End If
i = i + 1
If i = 10 Then
MsgBox("你已完成所有測驗。請查看你的成績并點擊退出")
Open Application.Path & "\test_result,txt" For Output As #1
For j = 0 To 9
Print #1, a(j, 0)
Print #1, "Answer: " & a(j, 5)
Print #1, "Your Choice: " & Choice(j)
Print #1
Next j
Print #1 "Your points:" & Points
Close #1
ShellExecute Me.hWnd, "", Application.Path & "\test_result,txt", "", "", 1
Exit Sub
Else
For j = 1 To 4
Me.Controls.Item(j - 1) .Text = a(i, j)
Next j
End If
End Sub
uj5u.com熱心網友回復:
都寫那么多了,再加把勁不就自己完成了?1、把a(9,5)擴充到a(9,6),最后一個儲存用戶的答案;在Button3_Click開始部分獲取當前題目的答案并儲存到a(i,6)里面;
2、最后統計的時候只需要判斷a(i,5)=a(i,6)?寫檔案的時候用fso很簡單的
uj5u.com熱心網友回復:
呵呵,他就是不知道怎樣把選擇結果存起來,無論存到哪里。uj5u.com熱心網友回復:
存盤結構:A表,題號,題干,選項A,選項B,選項C,選項D,答案,分值
B表,考生號,題號,答案
select B表.考生號, sum(A表.分值) from B表,A 表
where A表.題號=B表.題號 and A表.答案=B表.答案
group by B表.考生號
隨手寫的,主要看思路,
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/105183.html
標籤:VB基礎類
下一篇:新手求教A星演算法
