论文首页哲学论文经济论文法学论文教育论文文学论文历史论文理学论文工学论文医学论文管理论文艺术论文 |
'设置控件默认值
Private Sub SetDefaultValue()
Dim ctl As Control
Dim i As Integer
'如果是新增,则清空所有文本框
'此处判断 m_obj为空与判断m_ViewType = vtAdd等效,但更安全
If m_obj Is Nothing Then
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
Else '用传入对象的值更新数据
With m_obj
txtCount.Text = .Count
txtReason.Text = .Reason
txtRemark.Text = .Remark
cboUnit.ListIndex = 0
dtpRegDate.Value = .RegDate
'检查输入有效性
Private Function CheckValid() As Boolean
CheckValid = False
If txtCount.Text = "" _
Or txtReason.Text = "" _
Or txtRemark.Text = "" Then
MsgBox "请填写完毕以上各项内容"
Exit Function
End If
If cboMerchName.Text = "" Then
MsgBox "请填写完毕以上各项内容"
Exit Function
End If
If Not IsNumeric(txtCount.Text) Then
MsgBox "数量请输入数字"
Exit Function
End If
If Not IsDate(dtpRegDate.Value) Then
MsgBox "请输入正确的日期格式"
Exit Function
End If
CheckValid = True
End Function
'保存数据
Private Sub SaveValue()
'给“成员变量”对象赋值
With m_obj
'注意以下利用RealString函数替换去除输入中的单引号
.Count = txtCount.Text
.Reason = RealString(txtReason.Text)
.Remark = RealString(txtRemark.Text)