开发实践教程1:试卷生成系统6.9 题型选择(FormSingleExamType)
Posted VB.Net
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了开发实践教程1:试卷生成系统6.9 题型选择(FormSingleExamType)相关的知识,希望对你有一定的参考价值。
版权声明:本文为博主原创文章,转载请在显著位置标明本文出处以及作者网名,未经作者允许不得用于商业目的。
在“试卷信息”窗体中添加题型、数量以及对应分数。
窗体设计如下:
图1-19
具体代码如下:
Imports System.Data.SqlClient
Public Class FormSingleExamType
Dim connection As SqlConnection
Dim lstExamTypeIndex As List(Of Integer)
Private Sub FormSingleExamType_Load(sender As Object, e As EventArgs) Handles MyBase.Load
connection = New SqlConnection(databaseConnString)
connection.Open()
lstExamTypeIndex = New List(Of Integer)
Call drawComboBox()
End Sub
Private Sub drawComboBox()
Dim sql As String
sql = "select 编号,类型名称 from 题类型表"
Dim command As New SqlCommand()
command.CommandText = sql
command.Connection = connection
Dim sqlReader As SqlDataReader
sqlReader = command.ExecuteReader()
If sqlReader.HasRows Then
Do While sqlReader.Read
cbExamType.Items.Add(sqlReader(1))
lstExamTypeIndex.Add(sqlReader(0))
Loop
End If
cbExamType.Text = cbExamType.Items(0)
sqlReader.Close()
End Sub
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
Dim parent As FormTestPaperInfo
parent = CType(Me.Owner, FormTestPaperInfo)
parent.examTypeIndex = lstExamTypeIndex(cbExamType.SelectedIndex)
parent.examType = cbExamType.Text
parent.examCount = nudCount.Value
parent.examScore = nudScore.Value
Me.Close()
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Dim parent As FormTestPaperInfo
parent = CType(Me.Owner, FormTestPaperInfo)
parent.examTypeIndex = 0
parent.examType = ""
parent.examCount = 0
parent.examScore = 0
Me.Close()
End Sub
End Class
由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供的参考。
学习更多vb.net知识,请参看 vb.net 教程 目录
以上是关于开发实践教程1:试卷生成系统6.9 题型选择(FormSingleExamType)的主要内容,如果未能解决你的问题,请参考以下文章
开发实践教程1:试卷生成系统6.1 登录界面(FormLogin)
开发实践教程1:试卷生成系统6.7 试卷生成(FormTestPaper)