求助vb大神,个人收支管理添加一个新功能

 我来答
山本位一
2017-04-21 · TA获得超过2986个赞
知道大有可为答主
回答量:1975
采纳率:50%
帮助的人:803万
展开全部
添加类别:
Option1.Value = False And Option2.Value = False Then
Dim str1 As Integer
str1 = MsgBox("请选择收支类型,否则将默认为-收", 4128, "收支类型必须指明")
Option1.Value = True
s = "收"
ElseIf Option1.Value = True Then
s = "收"
ElseIf Option2.Value = True Then
s = "支"
End If
If Text_class_add.Text = "" Or Text_class_add.Text = "(不超过12字)" Then
Dim str2 As Integer
str2 = MsgBox("请输入收支类型的名称", 4128, "收支名称必须指明")
Else
On Error GoTo showerror
With rst
.AddNew
.Fields.Item("收支类型").Value = Text_class_add.Text
.Fields.Item("收支").Value = s
.Fields.Item("说明").Value = Text_shuoming
.Update
.Requery
End With
'------------显示全部记录
List_class.Clear
rst.MoveFirst
i = 0
Do While Not rst.EOF
List_class.List(i) = rst.Fields("收支类型").Value
List_shouzhi.List(i) = rst.Fields("收支").Value
rst.MoveNext
i = i + 1

Loop'------------结束
GoTo jump
showerror: MsgBox Err.Description
With dbs
If .State = adStateOpen Then
.Close
End If
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = App.Path & "\mymoney.mdb"
.Open
End With
With rst
If .State = adStateOpen Then
.Close
End If
.LockType = adLockOptimistic
.ActiveConnection = dbs
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open "收支类型表", Options:=adCmdTable

End With
jump:
End If

Text_class_add.Text = ""
Text_shuoming.Text = ""
Option1.Value = False
Option2.Value = False

End Sub
修改类别:
With rst
If .State = adStateOpen Then
.Close
End If
.LockType = adLockOptimistic
.ActiveConnection = dbs
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open "收支类型表", Options:=adCmdTable

End With
rst.MoveFirst
Do While Not rst.EOF
If ss = rst.Fields("收支类型").Value Then
If Option1.Value = True Then
s = "收"
ElseIf Option2.Value = True Then
s = "支"
End If

If Text_class_add.Text = "" Or Text_class_add.Text = "(不超过12字)" Then
Dim str2 As Integer
str2 = MsgBox("请输入收支类型的名称", 4128, "收支名称必须指明")
Else

On Error GoTo showerror

With rst

.Fields.Item("收支类型").Value = Text_class_add.Text
.Fields.Item("收支").Value = s
.Fields.Item("说明").Value = Text_shuoming
.Update
.Requery
End With
'------------显示全部记录
List_class.Clear
rst.MoveFirst
i = 0
Do While Not rst.EOF
List_class.List(i) = rst.Fields("收支类型").Value
List_shouzhi.List(i) = rst.Fields("收支").Value
rst.MoveNext
i = i + 1

Loop
'------------结束
GoTo jump
showerror:
MsgBox Err.Description
With dbs
If .State = adStateOpen Then
.Close
End If
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = App.Path & "\mymoney.mdb"
.Open
End With
With rst
If .State = adStateOpen Then
.Close
End If
.LockType = adLockOptimistic
.ActiveConnection = dbs
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open "收支类型表", Options:=adCmdTable

End With
jump:

Text_class_add.Text = ""
Text_shuoming.Text = ""
Option1.Value = False
Option2.Value = False
End If
Exit Do
End If
rst.MoveNext
Loop
Command_update.Enabled = False
Command_class_add.Enabled = True
End Sub
收支类型说明:
ss = List_class.Text
m = 0 '<----------判断哪条记录被选定

For i = 0 To List_class.ListCount - 1

If List_class.Selected(i) = True Then
m = i
Exit For
End If
Next i
List_shouzhi.Selected(m) = True

rst.Requery

Do While Not rst.EOF
If List_class.Text = rst.Fields("收支类型").Value Then

Command_class_add.Enabled = False
Command_update.Enabled = True

Text_class_add.Text = rst.Fields("收支类型")
If IsNull(rst.Fields("说明").Value) Then
Label_shuoming.Caption = "无详细说明"
Text_shuoming.Text = ""
Else
Label_shuoming.Caption = rst.Fields("说明").Value
Text_shuoming.Text = rst.Fields("说明").Value
End If
If rst.Fields("收支") = "收" Then
Option1.Value = True
Else
Option2.Value = True
End If

Exit Do
End If
rst.MoveNext
Loop
rst.Requery
End Sub
银行卡添加:
With rst

.AddNew
.Fields(0).Value = Text_cardnum.Text
.Fields(1).Value = Text_cardname2.Text
.Fields(2).Value = Text_bankname2.Text
.Fields(3).Value = DTPicker_card2.Value
.Fields(4).Value = Text_cardmore2.Text
.Update
.Requery
End With
'------------显示全部记录
List_cardname.Clear
' rst.MoveFirst
i = 0
Do While Not rst.EOF
List_cardname.List(i) = rst.Fields(1).Value
rst.MoveNext
i = i + 1
Loop
'------------结束
Text_cardnum.Text = ""
Text_cardname2.Text = ""
Text_bankname2.Text = ""
DTPicker_card2.Value = Date
Text_cardmore2.Text = ""
GoTo jump
showerror: MsgBox Err.Description
cnndata
rsttable "银行卡表"
jump:
End Sub
银行卡删除:
s = MsgBox("确定要删除该卡吗?删除后该卡的所有收支记录会丢失", vbYesNo, "删除选定银行卡")
If s = 6 Then

On Error GoTo showerror
rst.Requery
rst.Move (List_cardname.ListIndex)
rst.Delete
rst.Requery
'------------显示全部记录
List_cardname.Clear
' rst.MoveFirst
i = 0
Do While Not rst.EOF
List_cardname.List(i) = rst.Fields(1).Value
rst.MoveNext
i = i + 1
Loop
Text_cardname1.Text = ""
Text_bankname1.Text = ""
DTPicker_card1.Value = Date
Text_cardmore1.Text = ""
GoTo jump
showerror: MsgBox Err.Description
cnndata
rsttable "银行卡表"
jump:
End If

End Sub

支出查询:

cnndata
'<---------初始显示当月全部类型的支出
If Combo_class.Text = "" Or Combo_class.Text = "全部支出类型" Then
'-------所有支出类型查询
If Check_zhi_all.Value = 1 Then
'--------所有类型,所有日期查询
sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支记录表.收支类型 <> '银行存款'"
ElseIf Check_zhi_all.Value = 0 Then
'---------所有类型,按月查询
sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支记录表.收支类型 <> '银行存款' and 收支记录表.收支日期 between #" & RTrim(Combo_year.Text) & "-" & RTrim(Combo_month.Text) & "-1#" & "and#" & RTrim(Combo_year.Text) & "-" & RTrim(Combo_month.Text) & "-" & daynum & "#"
End If

Else
'--------固定类型查询
If Check_zhi_all.Value = 1 Then
'---------固定类型,所有日期查询
sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支类型表.收支类型='" & RTrim(Combo_class.Text) & "'"
ElseIf Check_zhi_all.Value = 0 Then
'----------固定类型,按日期查询
sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支类型表.收支类型='" & RTrim(Combo_class.Text) & "'and 收支记录表.收支日期 between #" & RTrim(Combo_year.Text) & "-" & RTrim(Combo_month.Text) & "-1#" & "and#" & RTrim(Combo_year.Text) & "-" & RTrim(Combo_month.Text) & "-" & daynum & "#"
End If

End If
面向科技
2024-12-04 广告
多维度数据对账分析: 账单与订单金额对账分析,发货单与订单数量对账分析待任意场景的金额或数量对账,对账成功、订单缺失、金额差异、融合对账、核销对账等数据埋点、编码映射、数据清洗、可视化埋点多种方式满足数据对账分析需要,实现多对多的数据对账,... 点击进入详情页
本回答由面向科技提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式