程序目前仅更新了A类数据题库。
1.自有背题模式
2.考试模式
程序下载:HAM业余无线电考试.zip
软件运行环境:windows7/8/10 程序编译环境:vs2017
源码:
'Imports System.ComponentModel
Imports System.IO
Imports System.Data.OleDb
Module Module1
Dim cn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim Access_path '地点路径
Dim Category As String '类别A,B,C
Sub Module_Str(Categorys)
Category = Categorys
End Sub
Dim FilePath = Application.StartupPath & "\Exercise_lib.accdb"
'Dim Category '类别函数
Sub Access_conn()
If Dir(FilePath) <> "" Then
Dim cnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Exercise_lib.accdb;Persist Security Info=False"
cn = New OleDbConnection(cnStr)
If Category = "A级" Or Category = "B级" Or Category = "C级" Then
'Dim sql As String = "select * from " & Category
'通过SQL查询语句进行排序,可以解决DataGridView1默认乱序问题
Dim sql As String = "select * from " & Category & " ORDER by ID" '按ID列升序排列" ORDER by ID DESC"按ID降序排列
da = New OleDbDataAdapter(sql, cn)
ds = New DataSet
da.Fill(ds, Category)
Form2.DataGridView1.DataSource = ds.Tables(0)
' Form2.DataGridView1.Columns(0).SortMode = DataGridViewColumnSortMode.Automatic
' Form4.DataGridView1.DataSource = Form2.DataGridView1.DataSource
Form4.DataGridView1.DataSource = ds.Tables(0)
'Form4.DataGridView1.Columns(0).SortMode = DataGridViewColumnSortMode.Automatic
Else
'MsgBox("请选择考试类别!", "提示")
'MessageBox"请选择考试类别!", vbOK, "提示"
End If
Else
MsgBox("系统缺少重要文件:数据库。",, "提示")
Form1.Close()
End If
End Sub
End Module
Public Class Form2
Dim Category_Name
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "自由背题模式" & "-" & Category_Name & " " & "QQ806666754"
Label3.Visible = False '标识
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
DataGridView1.Visible = False
CheckBox1.Checked = True
Access_conn() '读取数据库
Radio_add()
End Sub
Private Sub Form2_Closed(sender As Object, e As EventArgs) Handles Me.Closed
Form1.Show()
End Sub
Sub Form2_Str(Categorys As String)
Category_Name = Categorys
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If CheckBox1.Checked = False Then
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
End If
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
'Label1.Text = DataGridView1.Rows(0).Cells(0).Value & "." & DataGridView1.Rows(0).Cells(1).Value
'RadioButton1.Text = DataGridView1.Rows(0).Cells(2).Value
'RadioButton2.Text = DataGridView1.Rows(0).Cells(3).Value
'RadioButton3.Text = DataGridView1.Rows(0).Cells(4).Value
'RadioButton4.Text = DataGridView1.Rows(0).Cells(5).Value
'Label2.Text = "正确答案:" & DataGridView1.Rows(0).Cells(6).Value
Label3.Text = DataGridView1.Rows.Count - 1
Radio_add()
End Sub
Dim n As Integer = 1
'顺序读取数据库
'下一题
Dim ds_str
Sub Radio_add()
If n <= DataGridView1.Rows.Count - 1 Then
Label1.Text = DataGridView1.Rows(n - 1).Cells(0).Value & "." & DataGridView1.Rows(n - 1).Cells(1).Value
RadioButton1.Text = DataGridView1.Rows(n - 1).Cells(2).Value
RadioButton2.Text = DataGridView1.Rows(n - 1).Cells(3).Value
RadioButton3.Text = DataGridView1.Rows(n - 1).Cells(4).Value
RadioButton4.Text = DataGridView1.Rows(n - 1).Cells(5).Value
ds_str = DataGridView1.Rows(n - 1).Cells(6).Value
Label2.Text = "正确答案:" & DataGridView1.Rows(n - 1).Cells(6).Value
If CheckBox1.Checked = True Then
If DataGridView1.Rows(n - 1).Cells(6).Value = "A" Then RadioButton1.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "B" Then RadioButton2.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "C" Then RadioButton3.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "D" Then RadioButton4.Checked = True
End If
n = n + 1
If n > DataGridView1.Rows.Count - 1 Then n = 1
Else
n = 1
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If CheckBox1.Checked = False Then
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
End If
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
Label3.Text = DataGridView1.Rows.Count - 1
Radio_just()
End Sub
'上一题
Sub Radio_just()
If 1 <= n <= DataGridView1.Rows.Count - 1 Then
Label1.Text = DataGridView1.Rows(n - 1).Cells(0).Value & "." & DataGridView1.Rows(n - 1).Cells(1).Value
RadioButton1.Text = DataGridView1.Rows(n - 1).Cells(2).Value
RadioButton2.Text = DataGridView1.Rows(n - 1).Cells(3).Value
RadioButton3.Text = DataGridView1.Rows(n - 1).Cells(4).Value
RadioButton4.Text = DataGridView1.Rows(n - 1).Cells(5).Value
ds_str = DataGridView1.Rows(n - 1).Cells(6).Value
Label2.Text = "正确答案:" & DataGridView1.Rows(n - 1).Cells(6).Value
If CheckBox1.Checked = True Then
If DataGridView1.Rows(n - 1).Cells(6).Value = "A" Then RadioButton1.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "B" Then RadioButton2.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "C" Then RadioButton3.Checked = True
If DataGridView1.Rows(n - 1).Cells(6).Value = "D" Then RadioButton4.Checked = True
End If
n = n - 1
If n < 1 Then n = 1
Else
n = 1
End If
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False Then
Label2.Visible = False
'Label4.Visible = True
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
Else
'Label4.Visible = False
Label2.Visible = True
If ds_str = "A" Then RadioButton1.Checked = True
If ds_str = "B" Then RadioButton2.Checked = True
If ds_str = "C" Then RadioButton3.Checked = True
If ds_str = "D" Then RadioButton4.Checked = True
End If
End Sub
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
Dim s = ""
If RadioButton1.Checked = True Then s = "A"
If ds_str = s Then
Label2.Visible = True
Label4.Visible = True
Label4.Text = "√"
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
Else
Label2.Visible = False
Label4.Text = "×"
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
Dim s = ""
If RadioButton2.Checked = True Then s = "B"
If ds_str = s Then
Label2.Visible = True
Label5.Visible = True
Label4.Text = ""
Label5.Text = "√"
Label6.Text = ""
Label7.Text = ""
Else
Label2.Visible = False
Label4.Text = ""
Label5.Text = "×"
Label6.Text = ""
Label7.Text = ""
End If
End Sub
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
Dim s = ""
If RadioButton3.Checked = True Then s = "C"
If ds_str = s Then
Label2.Visible = True
Label6.Visible = True
Label4.Text = ""
Label5.Text = ""
Label6.Text = "√"
Label7.Text = ""
Else
Label2.Visible = False
Label4.Text = ""
Label5.Text = ""
Label6.Text = "×"
Label7.Text = ""
End If
End Sub
Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged
Dim s = ""
If RadioButton4.Checked = True Then s = "D"
If ds_str = s Then
Label2.Visible = True
Label7.Visible = True
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = "√"
Else
Label2.Visible = False
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = "×"
End If
End Sub
End Class
本文
© 版权声明
THE END
暂无评论内容