以下是引用片段:
其关键代码实现过程如下: Private Sub btnSave_Click() '判断信息是否正确
If Me.txtKmmc.Tag = "" Or Me.txtTxmc.Tag = "" Then MsgBox "题型或科目不能为空!" Exit Sub End If If Me.txtTmnr.Text = "" Or Me.txtTmda.Text = "" Then MsgBox "题目或答案不能为空!" Exit Sub End If '根据不同的标志 添加或更新当前的试题 Dim strResult As String If Me.Tag = "" Then strResult = Exec_SqL("insert into TK(kmid,txid,tmnr,tmda,tmfs,ygid,lrsj) values (" & CInt(Me.txtKmmc.Tag) & "," & CInt(Me.txtTxmc.Tag) & ",'" & Me.txtTmnr.Text & "','" & Me.txtTmda.Text & "'," & Val(Me.txtFs.Text) & "," & strRyid & ",'" & Me.txtLrsj.Text & "') ") If strResult <> "OK" Then MsgBox strResult End If Else strResult = Exec_SqL("update TK set kmid=" & CInt(Me.txtKmmc.Tag) & ",txid=" & CInt(Me.txtTxmc.Tag) & ",tmnr='" & Me.txtTmnr.Text & "',tmda='" & Me.txtTmda.Text & "',tmfs=" & Val(Me.txtFs.Text) & ",ygid=" & strRyid & ",lrsj='" & Me.txtLrsj.Text & "' where tkid=" & CInt(Me.Tag)) If strResult <> "OK" Then MsgBox strResult End If End If '根据不同的标志 刷新不同窗体的列表 If Me.labList.Caption = "List" Then frmStList.InitList ElseIf Me.labList.Caption = "Sdzj" Then frmSdzj.InitList End If Unload Me End Sub
|