【使用滚动条制作调色板】【收支记账程序】【输入中文字符英文字符】
使用滚动条制作调色板
Public Sub 设置背景色()
If Me.TextR <> "" And Me.TextG <> "" And Me.TextB <> "" Then
Me.颜色显示.BackColor = RGB(CInt(Me.TextR), CInt(Me.TextG), CInt(Me.TextB))
End If
End Sub
Private Sub Form_Load()
Call 设置背景色
End Sub
Private Sub ScrollBarB_Updated(Code As Integer)
Me.TextB = CInt(Me.ScrollBarB.Value)
Call 设置背景色
End Sub
Private Sub ScrollBarG_Updated(Code As Integer)
Me.TextG = CInt(Me.ScrollBarG.Value)
Call 设置背景色
End Sub
Private Sub ScrollBarR_Updated(Code As Integer)
Me.TextR = CInt(Me.ScrollBarR.Value)
Call 设置背景色
End Sub
收支记账程序
收支记账程序
Private Sub Command生成报表_Click()
DoCmd.OpenReport "账户收支报表", acViewReport, , "账户名称='" & Me.账户名称 & "'"
End Sub
Private Sub Form_AfterUpdate()
Me.账户列表.Requery
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo 数据更新前提醒_Err
If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then
Beep
Else
DoCmd.RunCommand acCmdUndo
End If
数据更新前提醒_Exit:
Exit Sub
数据更新前提醒_Err:
MsgBox Error$
Resume 数据更新前提醒_Exit
End Sub
Private Sub Form_Load()
Me.账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Me.账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Me.账户余额 = Me.账户收入 - Me.账户支出
Call 总收支计算
End Sub
收支数据表
Private Sub Form_AfterUpdate()
Call 总收支计算
Forms(收支记账程序).账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Forms(收支记账程序).账户名称 & "'"), 0)
Forms(收支记账程序).账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Forms(收支记账程序).账户名称 & "'"), 0)
Forms(收支记账程序).账户余额 = Forms(收支记账程序).账户收入 - Forms(收支记账程序).账户支出
End Sub
Private Sub 日期_DblClick(Cancel As Integer)
Me.日期 = Date
End Sub
账户收支查询数据表
Private Sub 账户名称_DblClick(Cancel As Integer)
Forms("收支记账程序").Filter = "账户名称='" & 账户名称 & "'"
Forms("收支记账程序").FilterOn = True
Forms("收支记账程序").账户名称.SetFocus
Forms("收支记账程序").账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Forms("收支记账程序").账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Forms("收支记账程序").账户余额 = Forms("收支记账程序").账户收入 - Forms("收支记账程序").账户支出
End Sub
模块1
Public Sub 总收支计算()
Forms("收支记账程序").总收入 = Nz(DSum("金额", "收支表", "收支='收入'"), 0)
Forms("收支记账程序").总支出 = Nz(DSum("金额", "收支表", "收支='支出'"), 0)
Forms("收支记账程序").总余额 = Forms("收支记账程序").总收入 - Forms("收支记账程序").总支出
End Sub
输入中文字符英文字符
Private Sub Command测试1_Click()
If Me.输入中文 <> "" Then
Dim i
Dim checkitem As String
Dim checktext As String
checktext = Trim(Me.输入中文)
'-----------------------------------------提取中文
For i = 1 To Len(checktext)
checkitem = Mid(checktext, i, 1)
If checkitem Like "[一-龥]" Then
Else
MsgBox "只能输入中文字符"
Exit Sub
End If
Next i
End If
End Sub
Private Sub Command测试2_Click()
If Me.输入英文 <> "" Then
Dim i
Dim checkitem As String
Dim checktext As String
checktext = Trim(Me.输入英文)
'-----------------------------------------提取中文
For i = 1 To Len(checktext)
checkitem = Mid(checktext, i, 1)
If checkitem Like "[a-zA-Z]" Then
Else
MsgBox "只能输入英文字符"
Exit Sub
End If
Next i
End If
End Sub
Private Sub Command提取_Click()
If Me.原文本 <> "" Then
Dim i
Dim checkitem As String
Dim checktext As String
checktext = Trim(Me.原文本)
'-----------------------------------------提取中文
For i = 1 To Len(checktext)
checkitem = Mid(checktext, i, 1)
If checkitem Like "[一-龥]" Then
Me.中文 = Me.中文 & checkitem
End If
Next i
'-----------------------------------------提取英文
For i = 1 To Len(checktext)
checkitem = Mid(checktext, i, 1)
If checkitem Like "[a-zA-Z]" Then
Me.英文 = Me.英文 & checkitem
End If
Next i
End If
End Sub