⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form2.frm

📁 个人理财的VB代码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   Begin VB.PictureBox Picture1 
      Height          =   855
      Left            =   240
      ScaleHeight     =   795
      ScaleWidth      =   4035
      TabIndex        =   8
      Top             =   2160
      Width           =   4095
      Begin VB.CommandButton Command2 
         Caption         =   "放弃(&X)"
         Height          =   375
         Left            =   2400
         TabIndex        =   10
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton Command1 
         Caption         =   "添加(&D)"
         Height          =   375
         Left            =   360
         TabIndex        =   9
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.ComboBox Combo1 
      Appearance      =   0  'Flat
      DataField       =   "类型"
      DataSource      =   "Data1"
      Height          =   300
      Left            =   960
      Locked          =   -1  'True
      TabIndex        =   7
      Text            =   "Combo1"
      Top             =   1560
      Width           =   1215
   End
   Begin VB.TextBox Text3 
      Appearance      =   0  'Flat
      DataField       =   "说明"
      DataSource      =   "Data1"
      Height          =   1335
      Left            =   2520
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      TabIndex        =   6
      Text            =   "Form2.frx":00C4
      Top             =   600
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Appearance      =   0  'Flat
      DataField       =   "钱额"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   960
      Locked          =   -1  'True
      TabIndex        =   1
      Text            =   "Text2"
      Top             =   960
      Width           =   975
   End
   Begin VB.TextBox Text1 
      Appearance      =   0  'Flat
      DataField       =   "日期"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   960
      Locked          =   -1  'True
      TabIndex        =   5
      Text            =   "Text1"
      Top             =   480
      Width           =   975
   End
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel4 
      Height          =   255
      Left            =   3000
      OleObjectBlob   =   "Form2.frx":00CA
      TabIndex        =   4
      Top             =   240
      Width           =   735
   End
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel3 
      Height          =   255
      Left            =   360
      OleObjectBlob   =   "Form2.frx":012C
      TabIndex        =   3
      Top             =   1560
      Width           =   735
   End
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel2 
      Height          =   255
      Left            =   360
      OleObjectBlob   =   "Form2.frx":018E
      TabIndex        =   2
      Top             =   960
      Width           =   615
   End
   Begin ACTIVESKINLibCtl.SkinLabel SkinLabel1 
      Height          =   255
      Left            =   360
      OleObjectBlob   =   "Form2.frx":01F0
      TabIndex        =   0
      Top             =   480
      Width           =   615
   End
   Begin ACTIVESKINLibCtl.Skin Skin1 
      Left            =   0
      OleObjectBlob   =   "Form2.frx":0252
      Top             =   0
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub Combo1_LostFocus()
'核对填写的项目是否与程序设定一样
Select Case Combo1.Text
Case "工资收入"
Case "经商收入"
Case "其它收入"
Case "生活支出"
Case "学习支出"
Case "娱乐支出"
Case "投资支出"
Case "其它支出"
 Case Else
 MsgBox "您输入的收支类别不合程序要求,这可能会造成计算及查询的不正确!" + Chr(13) + "请点击右边的下拉箭头,并从中选择一个类别!", 48, "类别错误"
 Combo1.SelStart = 0
 Combo1.SelLength = Len(Combo1.Text)
 Combo1.SetFocus
 End Select
End Sub

Private Sub Command1_Click()
Select Case Command1.Caption
Case "添加(&D)"
Data1.Recordset.AddNew '添加数据
  Command1.Caption = "保存(&D)"
 Command2.Enabled = False
 Text1.Text = Date '显示计算机时间
 '---------------------------
 Text1.Locked = False
 Text2.Locked = False
 Text3.Locked = False
 Combo1.Locked = False
 

Case "保存(&D)"
If Text1.Text = "" Then
Text1.Text = "-"
End If
If Text2.Text = "" Then
Text2.Text = "0"
End If
If Text3.Text = "" Then
Text3.Text = "-"
End If
Data1.Recordset.Update '更新数据库
Data1.Recordset.MoveLast '显示数据库最后一条记录
  Command1.Caption = "添加(&D)"
  Command2.Enabled = True
  '---------------------------
 Text1.Locked = True
 Text2.Locked = True
 Text3.Locked = True
 Combo1.Locked = True
 '----------------------------------------------------
If Combo1.Text = "工资收入" Then
Label2.Caption = Val(Label2.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "经商收入" Then
Label3.Caption = Val(Label3.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "其它收入" Then
Label4.Caption = Val(Label4.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "生活支出" Then
Label5.Caption = Val(Label5.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "学习支出" Then
Label6.Caption = Val(Label6.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "娱乐支出" Then
Label7.Caption = Val(Label7.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "投资支出" Then
Label8.Caption = Val(Label8.Caption) + Val(Text2.Text)
End If
If Combo1.Text = "其它支出" Then
Label9.Caption = Val(Label9.Caption) + Val(Text2.Text)
 End If
 '---------------------------
 
End Select
Data2.Recordset.Edit '修改
 Data2.Recordset.Update '更新数据库
End Sub

Private Sub Command2_Click()
Unload Me '关闭增加窗体Form1!
End Sub

Private Sub Form_Load()
'-----------------------------------------------------------------------------
'为界面添加皮肤
Skin1.LoadSkin App.Path & "\chizh.skn"
Skin1.ApplySkin Me.hwnd
'-----------------------------------------------------------------------------
'类型各个项目
Combo1.Text = "经商收入" '初始显示
Combo1.AddItem "工资收入"
Combo1.AddItem "经商收入"
Combo1.AddItem "其它收入"
Combo1.AddItem "生活支出"
Combo1.AddItem "学习支出"
Combo1.AddItem "娱乐支出"
Combo1.AddItem "投资支出"
Combo1.AddItem "其它支出"
'------------------------------------------------------------------------------
'设置对VB数据库连接的动态路径
Dim str As String '定义
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If
Data1.DatabaseName = str & "\zong.mdb"
Data1.RecordSource = "jilu"
Data1.Connect = ";pwd=suguidi"
Data1.Refresh
'------------------------------------------------------------------------------
Data2.DatabaseName = str & "\zong.mdb"
Data2.RecordSource = "jixan"
Data2.Connect = ";pwd=suguidi"
Data2.Refresh
'------------------------------------------------------------------------------
If Data1.Recordset.BOF = False Then
Data1.Recordset.MoveLast '显示数据库最后一条记录
End If
'-----------------------------------------------------------------------------

End Sub

Private Sub Form_Unload(Cancel As Integer)
Form1!Data1.Recordset.Requery '刷新数据库
Form1!Data2.Recordset.Requery '刷新数据库
 '-----------------------------
 If Form1!Data1.Recordset.EOF = False Then '如果记录不是最后一条然后
 Form1!Data1.Recordset.MoveLast '显示数据库最后一条记录
End If
Form1!Data2.Recordset.MoveLast '显示数据库最后一条记录
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
'限定在日期写入的必须数字和“—”
If KeyAscii >= 48 And KeyAscii <= 57 Then
ElseIf KeyAscii = 8 Then
ElseIf KeyAscii = Asc("-") Then
Else
KeyAscii = 0
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
'限定在金额写入的必须数字
If KeyAscii >= 48 And KeyAscii <= 57 Then
ElseIf KeyAscii = 8 Then
ElseIf KeyAscii = Asc(".") Then
Else
KeyAscii = 0
End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -