📄 cashnote.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form cashnote
Caption = "NoteVlue"
ClientHeight = 6780
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6780
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton ex
Caption = "exit"
Height = 375
Left = 3240
TabIndex = 8
Top = 1800
Width = 975
End
Begin VB.CommandButton dela
Caption = "delete"
Height = 300
Left = 1800
TabIndex = 7
Top = 1800
Width = 1095
End
Begin VB.CommandButton ok
Caption = "ok"
Height = 255
Left = 480
TabIndex = 6
Top = 1800
Width = 975
End
Begin MSFlexGridLib.MSFlexGrid MSFGType
Height = 4095
Left = 240
TabIndex = 5
Top = 2280
Width = 4335
_ExtentX = 7646
_ExtentY = 7223
_Version = 393216
End
Begin VB.TextBox amount
Height = 270
Left = 1800
TabIndex = 4
Top = 1440
Width = 1815
End
Begin VB.ComboBox Cashtype
Height = 300
Left = 1800
Style = 2 'Dropdown List
TabIndex = 3
Top = 960
Width = 1815
End
Begin VB.Label Label3
Caption = "Value"
Height = 255
Left = 720
TabIndex = 2
Top = 1440
Width = 855
End
Begin VB.Label Label2
Caption = "Cash"
Height = 375
Left = 600
TabIndex = 1
Top = 960
Width = 975
End
Begin VB.Label Label1
Caption = "initial Note Value"
Height = 255
Left = 720
TabIndex = 0
Top = 360
Width = 3135
End
End
Attribute VB_Name = "cashnote"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub amount_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57 '0-9,這裏還可以限制只能輸入哪幾個數字
Exit Sub
Case 8 '退格鍵
Exit Sub
Case 46 ' .键 Delete鍵
If InStr(cashamount, ".") = 0 Then
Exit Sub
Else
KeyAscii = 0
End If
Case 45
If InStr(cashamount, "-") = 0 Or InStr(cashamount, "-") = 1 Then
Exit Sub
Else
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub dela_Click()
On Error GoTo Err_deleter_Click
Dim db As DAO.Database
Set db = DAO.OpenDatabase(App.Path + "\cashsys.mdb")
Dim tttid
MSFGType.Col = 0
tttid = MSFGType.Text
Dim tttvalue
MSFGType.Col = 2
tttvalue = MSFGType.Text
If MsgBox("realy delete " + tttvalue + "?", vbYesNo) = vbYes Then
db.Execute " delete from cashtypeforpandian where cashtype=" + tttid + " and cashmianzhi=" + tttvalue
Call fillgrid
MsgBox "deleted'"
End If
db.Close
Exit_deleter_Click:
Exit Sub
Err_deleter_Click:
MsgBox Err.Description
Resume Exit_deleter_Click
End Sub
Private Sub ex_Click()
Unload Me
End Sub
Private Sub Form_Load()
MSFGType.FormatString = " CASHTYPE | CASH NAME | cash Value"
'SELECT cashtype.ID, cashtype.CASHTYPE, cashtype.CASHNAME, cashtype.ABBRNAMEFROM cashtype;
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DAO.OpenDatabase(App.Path + "\cashsys.mdb")
Set rs = db.OpenRecordset("SELECT str(CASHTYPE) +'|'+CASHNAME as IDAndName FROM cashtype")
Do While Not rs.EOF
Cashtype.AddItem rs("IDAndName")
rs.MoveNext
Loop
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
'SELECT DISTINCT a.CASHTYPE, a.CASHNAME AS cashname, b.cashmianzhi FROM CASHtype AS a INNER JOIN cashtypeforpandian AS b ON a.CASHTYPE=b.cashtype ORDER BY a.CASHTYPE, b.cashmianzhi DESC;
Call fillgrid
End Sub
Private Sub fillgrid()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DAO.OpenDatabase(App.Path + "\cashsys.mdb")
Set rs = db.OpenRecordset("SELECT DISTINCT a.CASHTYPE, a.CASHNAME , b.cashmianzhi FROM CASHtype AS a INNER JOIN cashtypeforpandian AS b ON a.CASHTYPE=b.cashtype ORDER BY a.CASHTYPE, b.cashmianzhi DESC ")
MSFGType.Clear
MSFGType.FormatString = " CASHTYPE | CASH NAME | cash Value"
MSFGType.Rows = 1
Do While Not rs.EOF
MSFGType.Rows = MSFGType.Rows + 1
MSFGType.Row = MSFGType.Rows - 1
MSFGType.Col = 0
MSFGType.Text = Str(rs("CASHTYPE"))
MSFGType.Col = 1
MSFGType.Text = rs("CASHNAME")
MSFGType.Col = 2
MSFGType.Text = rs("cashmianzhi")
rs.MoveNext
Loop
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub ok_Click()
On Error GoTo Err_savedata_Click
If Cashtype.ListIndex = -1 Then
MsgBox "pls select Cash type"
Cashtype.SetFocus
Exit Sub
End If
If Trim(amount.Text) = "" Then
MsgBox "pls inputnumber"
amount.SetFocus
Exit Sub
End If
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DAO.OpenDatabase(App.Path + "\cashsys.mdb")
Dim tttid
tttid = Left(Cashtype.Text, InStr(Cashtype.Text, "|") - 1)
Set rs = db.OpenRecordset("SELECT * FROM cashtypeforpandian where cashtype=" + tttid + " and cashmianzhi=" + Trim(amount.Text) + " ORDER BY cashtype ,cashmianzhi DESC")
If rs.EOF = False Then
MsgBox " exist already!"
amount.SetFocus
Exit Sub
End If
db.Execute " insert into cashtypeforpandian (cashtype,cashmianzhi) values (" + tttid + "," + Trim(amount.Text) + " )"
Call fillgrid
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
amount.Text = 0
Cashtype.SetFocus
MsgBox "saved"
Exit_savedata_Click:
Exit Sub
Err_savedata_Click:
MsgBox Err.Description
Resume Exit_savedata_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -