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

📄 form3.frm

📁 利用VB6.0写的应用程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form3 
   Caption         =   "Form3"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form3"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   2760
      TabIndex        =   3
      Top             =   1200
      Width           =   1695
   End
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   600
      TabIndex        =   2
      Top             =   1200
      Width           =   1695
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   2760
      TabIndex        =   1
      Top             =   360
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   600
      TabIndex        =   0
      Top             =   360
      Width           =   1695
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As ADODB.Connection
   Dim rs As ADODB.Recordset
Private Sub Command1_Click()
   Dim i, j As Integer
   Dim s, r As Single
   Dim strn, strm, strl As String

   Set cn = New ADODB.Connection
   cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security Info=False;Data Source=mymdb.mdb"
      
   Set rs = New ADODB.Recordset
   rs.CursorType = adOpenKeyset
   rs.LockType = adLockOptimistic
   rs.Open "select * from 历史", cn
   
   If rs.RecordCount >= 30 Then
      rs.MoveFirst
      rs.Delete
   End If
   
   rs.MoveFirst
   For i = 1 To rs.RecordCount
       strn = rs.Fields("序号")
       j = Val(strn)
       j = j - 1
       strm = Str(j)
       rs.Fields("序号") = strm
       rs.Update
       rs.MoveNext
       If rs.EOF = True Then rs.MoveFirst
    Next
    
   rs.AddNew
   rs.Fields("序号") = "30"
   rs.Fields("日期") = Text1.Text
   rs.Fields("湿度") = Text2.Text
   rs.Fields("等级") = Text3.Text
   rs.Update
   Text1.Text = ""
   Text2.Text = ""
   Text3.Text = ""
   
   rs.MoveFirst
   s = 0
   For i = 1 To rs.RecordCount
       strl = rs.Fields("湿度")
       s = s + Val(strl)
       rs.MoveNext
       If rs.EOF = True Then rs.MoveFirst
   Next
   r = s / 30
   'Form1.Text1.Text = Str(r)
   'If r < 10 Then Form1.Text4.Text = "过干"
   'If 10 <= r < 20 Then Form1.Text4.Text = "干燥"
   'If 20 <= r < 50 Then Form1.Text4.Text = "适宜"
   'If 50 <= r < 90 Then Form1.Text4.Text = "湿润"
   'If r >= 90 Then Form1.Text4.Text = "过湿"
   rs.Close
   MsgBox "成功插入一条记录"
End Sub

⌨️ 快捷键说明

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