📄 form1.vb
字号:
Imports System.data
Imports System.data.Oledb
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.MenuItem4 = New System.Windows.Forms.MenuItem
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(208, 112)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 32)
Me.Button1.TabIndex = 0
Me.Button1.Text = "开始记时"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(208, 176)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 32)
Me.Button2.TabIndex = 1
Me.Button2.Text = "停止记时"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(40, 136)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 32)
Me.Button3.TabIndex = 2
Me.Button3.Text = "抽签"
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem4})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2, Me.MenuItem3})
Me.MenuItem1.Text = "系统"
'
'MenuItem2
'
Me.MenuItem2.Index = 0
Me.MenuItem2.Text = "设置"
'
'MenuItem3
'
Me.MenuItem3.Index = 1
Me.MenuItem3.Text = "退出"
'
'MenuItem4
'
Me.MenuItem4.Index = 1
Me.MenuItem4.Text = "其他"
'
'Timer1
'
Me.Timer1.Interval = 500
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 50.0!)
Me.Label1.ForeColor = System.Drawing.SystemColors.Highlight
Me.Label1.Location = New System.Drawing.Point(72, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 88)
Me.Label1.TabIndex = 3
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.Text = "上课提问"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
wt1 = wt1 - 1
Label1.Text = wt1 + 1
If wt1 = -1 Then
Timer1.Enabled = False
If MsgBox("时间到了!请问是否随机点一位同学?", MsgBoxStyle.OKCancel = MsgBoxResult.OK) Then
Dim NoNo As Int16
NoNo = Int((43 * Rnd()) + 1)
Dim NoStr As String
If NoNo < 10 Then
NoStr = "0" & CStr(NoNo)
Else
NoStr = CStr(NoNo)
End If
MsgBox("请学号为200416032" & NoStr & "的同学回答此问题!")
End If
End If
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Dim set1 As New SettingDig
set1.Show()
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Randomize()
Dim NoNo As Int16
NoNo = CInt(Int((43 * Rnd()) + 1))
Dim conn As New OleDbConnection("provider=microsoft.Jet.Oledb.4.0;Data Source=" & "ts.mdb")
Dim mycommand As New OleDbCommand("select * from 学生", conn)
conn.Open()
Dim myReader As OleDbdataReader
myReader = mycommand.ExecuteReader()
While myReader.Read
If myReader.GetValue(0) = NoNo Then
MsgBox("恭喜" & myReader.GetValue(1).ToString & "同学,你被抽中了!")
End If
End While
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Randomize()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
wt1 = WaitTime
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -