www.pudn.com > textmanager.rar > FrmSeachCJ.frm, change:2005-04-12,size:26236b


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" 
Begin VB.Form FrmSeachCJ  
   Caption         =   "成绩查询" 
   ClientHeight    =   3615 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   5250 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   ScaleHeight     =   8595 
   ScaleWidth      =   11880 
   StartUpPosition =   3  '窗口缺省 
   WindowState     =   2  'Maximized 
   Begin VB.Frame Frame3  
      Caption         =   "成绩查询结果" 
      Height          =   5955 
      Left            =   195 
      TabIndex        =   17 
      Top             =   120 
      Width           =   11415 
      Begin MSDataGridLib.DataGrid DGScore  
         Height          =   5625 
         Left            =   165 
         TabIndex        =   18 
         Top             =   255 
         Width           =   11130 
         _ExtentX        =   19632 
         _ExtentY        =   9922 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         BackColor       =   15267064 
         HeadLines       =   1 
         RowHeight       =   18 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ColumnCount     =   2 
         BeginProperty Column00  
            DataField       =   "" 
            Caption         =   "" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column01  
            DataField       =   "" 
            Caption         =   "" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         SplitCount      =   1 
         BeginProperty Split0  
            MarqueeStyle    =   3 
            BeginProperty Column00  
            EndProperty 
            BeginProperty Column01  
            EndProperty 
         EndProperty 
      End 
   End 
   Begin VB.Frame Frame4  
      Caption         =   "成绩查询条件(置空时表示不加入该条件)" 
      Height          =   1980 
      Left            =   210 
      TabIndex        =   0 
      Top             =   6120 
      Width           =   11415 
      Begin MSComCtl2.UpDown UDBan  
         Height          =   315 
         Left            =   10155 
         TabIndex        =   28 
         Top             =   660 
         Width           =   270 
         _ExtentX        =   476 
         _ExtentY        =   556 
         _Version        =   393216 
         Value           =   1 
         BuddyControl    =   "TxTBan" 
         BuddyDispid     =   196611 
         OrigLeft        =   5430 
         OrigTop         =   1350 
         OrigRight       =   5700 
         OrigBottom      =   1665 
         Max             =   25 
         Min             =   1 
         SyncBuddy       =   -1  'True 
         BuddyProperty   =   0 
         Enabled         =   -1  'True 
      End 
      Begin VB.TextBox TxTBan  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   9810 
         TabIndex        =   27 
         Text            =   "1" 
         Top             =   660 
         Width           =   330 
      End 
      Begin VB.CheckBox CheBan  
         Appearance      =   0  'Flat 
         BackColor       =   &H8000000A& 
         Caption         =   "班别" 
         ForeColor       =   &H80000008& 
         Height          =   210 
         Left            =   9165 
         TabIndex        =   26 
         Top             =   720 
         Width           =   675 
      End 
      Begin VB.ComboBox CmbKeMu  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         Left            =   645 
         Style           =   2  'Dropdown List 
         TabIndex        =   23 
         Top             =   1350 
         Width           =   1485 
      End 
      Begin VB.ComboBox CmbNianJI  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         Left            =   2775 
         Style           =   2  'Dropdown List 
         TabIndex        =   22 
         Top             =   1350 
         Width           =   1485 
      End 
      Begin VB.Frame Frame1  
         Height          =   960 
         Left            =   4665 
         TabIndex        =   19 
         Top             =   975 
         Width           =   6645 
         Begin VB.CheckBox CheDel  
            Caption         =   "删除所有查询结果" 
            ForeColor       =   &H00FF0000& 
            Height          =   285 
            Left            =   360 
            TabIndex        =   32 
            Top             =   135 
            Width           =   1755 
         End 
         Begin VB.CommandButton CmdDel  
            Caption         =   "成绩删除" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   285 
            TabIndex        =   31 
            Top             =   450 
            Width           =   1215 
         End 
         Begin VB.CommandButton Command4  
            Caption         =   "打印成绩表" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   4155 
            TabIndex        =   30 
            Top             =   450 
            Width           =   1290 
         End 
         Begin VB.CommandButton Command3  
            Caption         =   "关 闭" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   5595 
            TabIndex        =   29 
            Top             =   450 
            Width           =   930 
         End 
         Begin VB.CommandButton Command1  
            Caption         =   "答卷浏览" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   2790 
            TabIndex        =   21 
            Top             =   450 
            Width           =   1215 
         End 
         Begin VB.CommandButton Command2  
            Caption         =   "查 询" 
            BeginProperty Font  
               Name            =   "宋体" 
               Size            =   10.5 
               Charset         =   134 
               Weight          =   400 
               Underline       =   0   'False 
               Italic          =   0   'False 
               Strikethrough   =   0   'False 
            EndProperty 
            Height          =   420 
            Left            =   1695 
            TabIndex        =   20 
            Top             =   450 
            Width           =   930 
         End 
      End 
      Begin VB.TextBox TXTtestID  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   810 
         TabIndex        =   8 
         Top             =   270 
         Width           =   705 
      End 
      Begin VB.TextBox TXTSname  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   4080 
         TabIndex        =   7 
         Top             =   255 
         Width           =   1530 
      End 
      Begin VB.ComboBox CmbCZS  
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   330 
         ItemData        =   "FrmSeachCJ.frx":0000 
         Left            =   630 
         List            =   "FrmSeachCJ.frx":0010 
         Style           =   2  'Dropdown List 
         TabIndex        =   6 
         Top             =   735 
         Width           =   675 
      End 
      Begin VB.TextBox TXTScore  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   1335 
         TabIndex        =   5 
         Top             =   750 
         Width           =   630 
      End 
      Begin VB.TextBox TXTTitle  
         Appearance      =   0  'Flat 
         BackColor       =   &H00E8F4F8& 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   315 
         Left            =   4875 
         TabIndex        =   2 
         Top             =   660 
         Width           =   3795 
      End 
      Begin VB.CheckBox CheDay  
         Appearance      =   0  'Flat 
         BackColor       =   &H8000000A& 
         Caption         =   "加入" 
         ForeColor       =   &H80000008& 
         Height          =   195 
         Left            =   6420 
         TabIndex        =   1 
         Top             =   330 
         Width           =   660 
      End 
      Begin MSComCtl2.DTPicker DTPS  
         Height          =   315 
         Left            =   7980 
         TabIndex        =   3 
         Top             =   240 
         Width           =   1440 
         _ExtentX        =   2540 
         _ExtentY        =   556 
         _Version        =   393216 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Format          =   24576001 
         CurrentDate     =   37024 
      End 
      Begin MSComCtl2.UpDown UDScore  
         Height          =   315 
         Left            =   1965 
         TabIndex        =   4 
         Top             =   750 
         Width           =   270 
         _ExtentX        =   476 
         _ExtentY        =   556 
         _Version        =   393216 
         BuddyControl    =   "TXTScore" 
         BuddyDispid     =   196625 
         OrigLeft        =   1995 
         OrigTop         =   705 
         OrigRight       =   2265 
         OrigBottom      =   1020 
         Max             =   300 
         SyncBuddy       =   -1  'True 
         BuddyProperty   =   0 
         Enabled         =   -1  'True 
      End 
      Begin MSComCtl2.DTPicker DTPE  
         Height          =   315 
         Left            =   9690 
         TabIndex        =   9 
         Top             =   255 
         Width           =   1440 
         _ExtentX        =   2540 
         _ExtentY        =   556 
         _Version        =   393216 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Format          =   24576001 
         CurrentDate     =   37024 
      End 
      Begin VB.Label Label2  
         AutoSize        =   -1  'True 
         BackStyle       =   0  'Transparent 
         Caption         =   "科目:" 
         ForeColor       =   &H00000000& 
         Height          =   180 
         Left            =   180 
         TabIndex        =   25 
         Top             =   1440 
         Width           =   450 
      End 
      Begin VB.Label Label9  
         AutoSize        =   -1  'True 
         BackStyle       =   0  'Transparent 
         Caption         =   "年级:" 
         ForeColor       =   &H00000000& 
         Height          =   180 
         Left            =   2310 
         TabIndex        =   24 
         Top             =   1440 
         Width           =   450 
      End 
      Begin VB.Label Label3  
         Caption         =   "考生姓名(支持模糊查询):" 
         Height          =   165 
         Left            =   1965 
         TabIndex        =   16 
         Top             =   315 
         Width           =   2160 
      End 
      Begin VB.Label Label1  
         Caption         =   "试卷ID:" 
         Height          =   165 
         Index           =   9 
         Left            =   150 
         TabIndex        =   15 
         Top             =   345 
         Width           =   720 
      End 
      Begin VB.Label Label6  
         AutoSize        =   -1  'True 
         Caption         =   "成绩:" 
         Height          =   180 
         Index           =   0 
         Left            =   150 
         TabIndex        =   14 
         Top             =   825 
         Width           =   540 
      End 
      Begin VB.Label Label7  
         AutoSize        =   -1  'True 
         Caption         =   "考试日期" 
         Height          =   180 
         Index           =   0 
         Left            =   7200 
         TabIndex        =   13 
         Top             =   330 
         Width           =   720 
      End 
      Begin VB.Label Label7  
         AutoSize        =   -1  'True 
         Caption         =   "到" 
         Height          =   180 
         Index           =   1 
         Left            =   9465 
         TabIndex        =   12 
         Top             =   315 
         Width           =   180 
      End 
      Begin VB.Label Label6  
         AutoSize        =   -1  'True 
         Caption         =   "试卷标题(支持模糊查询)" 
         Height          =   180 
         Index           =   1 
         Left            =   2895 
         TabIndex        =   11 
         Top             =   735 
         Width           =   1980 
      End 
      Begin VB.Label Label8  
         AutoSize        =   -1  'True 
         Caption         =   "(      )" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   210 
         Left            =   6330 
         TabIndex        =   10 
         Top             =   315 
         Width           =   840 
      End 
   End 
End 
Attribute VB_Name = "FrmSeachCJ" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Dim KeMuIdArr() As Long '科目id数组 
Dim NianJiIdArr() As Long 
 
Private Sub CmdDel_Click() 
 If CheDel.Value <> 1 Then 
   '删除单个成绩 
   If DGScore.Row < 0 Then 
      MsgBox "你没有选择你要删除的成绩!" 
    Else 
     If MsgBox("这是一个很危险的动作,你会删除所查询的同学的成绩,你确定吗?", vbYesNo + 48, "提示!") = vbYes Then 
      DB.Execute "delete from score where id=" & DGScore.Columns(8).Text 
      DB.Execute "delete from scoreTK where id=" & DGScore.Columns(8).Text 
      DB.Execute "delete from scorePD where id=" & DGScore.Columns(8).Text 
      DB.Execute "delete from scoreWD where id=" & DGScore.Columns(8).Text 
      DB.Execute "delete from scoreZW where id=" & DGScore.Columns(8).Text 
      Command2_Click 
     End If 
   End If 
 End If 
End Sub 
 
Private Sub Command1_Click() 
  Dim IdStr As Long 
  If DGScore.ApproxCount <= 0 Or DGScore.Row < 0 Then 
     MsgBox "你没有选择要查看的试卷!" 
     Exit Sub 
  End If 
  IdStr = Val(DGScore.Columns(8).Text) 
  CreateScoreHTML App.Path + "\temp.html", IdStr 
  FrmView.Web.Navigate App.Path + "\temp.html" 
  FrmView.Show 1 
End Sub 
'得到查询条件的字符串 
Function GetTJStr() As String 
   '定义查询条件,保存各个查询条件 
 Dim SqlTID As String 
 Dim SqlName As String 
 Dim SqlScore As String 
 Dim SqlTitle As String 
 Dim SqlDay As String 
 Dim SqlKeMu As String 
 Dim SqlNianJi As String 
 Dim SqlBan As String 
 '设置试卷编号查询条件 
 If TXTtestID.Text <> "" Then 
   SqlTID = " and score.testid=" + TXTtestID.Text 
  Else 
   SqlTID = "" 
 End If 
 '设置姓名关键字 
 If TXTSname.Text <> "" Then 
   SqlName = " and kaosheng.name like '%" + TXTSname.Text + "%'" 
  Else 
   SqlName = "" 
 End If 
 '设置试卷标题 
 If TXTTitle.Text <> "" Then 
   SqlTitle = " and test.title like '%" + TXTTitle.Text + "%'" 
  Else 
   SqlTitle = "" 
 End If 
 '设置分数 
 If TXTScore.Text <> "" Then 
   SqlScore = " and score.score" + CmbCZS.Text + TXTScore.Text 
  Else 
   SqlScore = "" 
 End If 
 '设置考试日期 
 If CheDay.Value = 1 Then 
   SqlDay = " and score.testtime>='" + Date2Str(DTPS.Value) + "' and score.testtime<='" + Date2Str(DTPE.Value) + "'" 
  Else 
   SqlDay = "" 
 End If 
  
  '设置年级 
 If CmbNianji.ListIndex = 0 Then 
   SqlNianJi = "" 
  Else 
   SqlNianJi = " and test.nianjiid=" & NianJiIdArr(CmbNianji.ListIndex - 1) 
 End If 
 '设置科目 
 If CmbKeMu.ListIndex = 0 Then 
   SqlKeMu = "" 
  Else 
   SqlKeMu = " and test.kemuid=" & KeMuIdArr(CmbKeMu.ListIndex - 1) 
 End If 
 '设置班级 
 If CheBan.Value = 1 Then 
   SqlBan = " and kaosheng.class=" & TXTBan.Text 
  Else 
   SqlBan = "" 
 End If 
 GetTJStr = SqlDay + SqlTID + SqlName + SqlTitle + SqlScore + SqlKeMu + SqlNianJi + SqlBan 
End Function 
Private Sub Command2_Click() 
 Dim adoRs As Recordset 
 Dim sql As String 
 Set adoRs = New Recordset 
 
'========================================== 
 sql = "select kaosheng.code as 学号,kaosheng.name as 考生姓名,score.testid as 试卷编号,test.title as 试卷标题,score.score as 考试成绩,test.zscore as 试卷总分,kemu.name as 科目,score.testtime as 考试时间,score.id as ID值 from score,kaosheng,test,kemu where kemu.id=test.kemuid and score.studentid=kaosheng.id and test.id=score.testid" 
 sql = sql + GetTJStr '得到条件字符串函数 
 adoRs.Open sql, DB, adOpenStatic, adLockOptimistic 
 Set DGScore.DataSource = adoRs 
 
End Sub 
Function Date2Str(ByVal DT As Date) As String  '日期转化成字符 
  Dim DateStr As String 
  DateStr = Format(DT, "YYYY-MM-DD") 
  Date2Str = DateStr 
End Function 
 
Private Sub Command3_Click() 
 Unload Me 
End Sub 
 
Private Sub Command4_Click() 
 Dim adoRs As Recordset 
 Dim sql As String 
 Set adoRs = New Recordset 
 
'========================================== 
 sql = "select kaosheng.code as 学号,kaosheng.name as 考生姓名,score.testid as 试卷编号,test.title as 试卷标题,score.score as 考试成绩,test.zscore as 试卷总分,kemu.name as 科目,score.testtime as 考试时间,score.id as ID值 from score,kaosheng,test,kemu where kemu.id=test.kemuid and score.studentid=kaosheng.id and test.id=score.testid" 
 sql = sql + GetTJStr + " order by score.score desc" '得到条件字符串函数 
 adoRs.Open sql, DB, adOpenStatic, adLockOptimistic 
 Set DGScore.DataSource = adoRs 
 If adoRs.EOF Then 
    MsgBox "你的查询结果为空,最好选择以年级、班或科目为单位查询!" 
    Exit Sub 
 End If 
 CreateScoreTable App.Path + "\temp.html", adoRs 
 FrmView.Web.Navigate App.Path + "\temp.html" 
 FrmView.Show 1 
End Sub 
 
Private Sub Form_Load() 
 CmbCZS.ListIndex = 0 
  '显示所有成绩表 
 Dim adoScoreRS As Recordset 
 Dim i As Integer 
 Set adoScoreRS = New Recordset 
 Dim adoRs As Recordset 
 Set adoRs = New Recordset 
 On Error Resume Next 
 '组合考生表查询 
 adoScoreRS.Open "select kaosheng.code as 学号,kaosheng.name as 考生姓名,score.testid as 试卷编号,test.title as 试卷标题,score.score as 考试成绩,test.zscore as 试卷总分,kemu.name as 科目,score.testtime as 考试时间,score.id as ID值 from score,kaosheng,test,kemu where kemu.id=test.kemuid and score.studentid=kaosheng.id and test.id=score.testid", DB, adOpenStatic, adLockOptimistic 
 Set DGScore.DataSource = adoScoreRS 
  
'年级 
adoRs.Open "select id,name from nianji", DB, adOpenStatic, adLockOptimistic 
CmbNianji.AddItem "所有年级" 
If Not adoRs.EOF Then 
  adoRs.MoveLast 
  adoRs.MoveFirst 
  ReDim NianJiIdArr(adoRs.RecordCount) As Long 
  For i = 0 To adoRs.RecordCount - 1 
     CmbNianji.AddItem adoRs.Fields("name").Value 
     NianJiIdArr(i) = adoRs.Fields("id").Value 
     adoRs.MoveNext 
  Next i 
End If 
adoRs.Close 
'科目 
adoRs.Open "kemu", DB, adOpenStatic, adLockOptimistic 
CmbKeMu.AddItem "所有科目" 
If Not adoRs.EOF Then 
  adoRs.MoveLast 
  adoRs.MoveFirst 
  ReDim KeMuIdArr(adoRs.RecordCount) As Long 
  For i = 0 To adoRs.RecordCount - 1 
     CmbKeMu.AddItem adoRs.Fields("name").Value 
     KeMuIdArr(i) = adoRs.Fields("id").Value 
     adoRs.MoveNext 
  Next i 
End If 
Set adoRs = Nothing 
CmbKeMu.ListIndex = 0 
CmbNianji.ListIndex = 0 
End Sub 
 
Private Sub TXTScore_KeyPress(KeyAscii As Integer) 
    If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46) Then 
  KeyAscii = 0 
 End If 
 
End Sub 
 
Private Sub TXTSname_KeyPress(KeyAscii As Integer) 
   If KeyAscii = 39 Then KeyAscii = -24145 
 
End Sub 
 
Private Sub TXTtestID_KeyPress(KeyAscii As Integer) 
    If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46) Then 
  KeyAscii = 0 
 End If 
 
End Sub 
 
Private Sub TxTTitle_KeyPress(KeyAscii As Integer) 
   If KeyAscii = 39 Then KeyAscii = -24145 
 
End Sub