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

📄 form1.frm

📁 自己编写的一个简易的日记本
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00008000&
   Caption         =   "日记本"
   ClientHeight    =   5970
   ClientLeft      =   555
   ClientTop       =   1830
   ClientWidth     =   8205
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5970
   ScaleWidth      =   8205
   Begin VB.CommandButton Command3 
      Caption         =   "查找"
      Height          =   375
      Left            =   6720
      TabIndex        =   9
      Top             =   2040
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "写入日记"
      Height          =   375
      Left            =   6720
      TabIndex        =   8
      Top             =   4920
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H0000C000&
      Caption         =   "添加日期"
      Height          =   375
      Left            =   6720
      MaskColor       =   &H0000FFFF&
      TabIndex        =   7
      Top             =   4200
      Width           =   1335
   End
   Begin VB.TextBox Text3 
      BackColor       =   &H0000C000&
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   6720
      TabIndex        =   5
      Top             =   1320
      Width           =   1335
   End
   Begin VB.ComboBox Combo1 
      BackColor       =   &H0000C000&
      ForeColor       =   &H0000FFFF&
      Height          =   300
      ItemData        =   "Form1.frx":0442
      Left            =   5400
      List            =   "Form1.frx":0455
      TabIndex        =   4
      Text            =   "晴天"
      Top             =   4320
      Width           =   855
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   4680
      Top             =   1560
   End
   Begin VB.TextBox Text2 
      BackColor       =   &H0000C000&
      Height          =   4095
      HideSelection   =   0   'False
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Top             =   120
      Width           =   6015
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H0000C000&
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1095
      Index           =   1
      Left            =   240
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   4800
      Width           =   6015
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      ForeColor       =   &H000000FF&
      Height          =   615
      Left            =   6720
      TabIndex        =   11
      Top             =   2760
      Width           =   1335
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Label1"
      ForeColor       =   &H0000FFFF&
      Height          =   180
      Left            =   6720
      TabIndex        =   10
      Top             =   240
      Width           =   540
   End
   Begin VB.Label Label9 
      BackStyle       =   0  'Transparent
      Caption         =   "输入要查找的日记日期或关键字 "
      ForeColor       =   &H0000FFFF&
      Height          =   420
      Left            =   6720
      TabIndex        =   6
      Top             =   840
      Width           =   1290
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "天气"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   180
      Left            =   4920
      TabIndex        =   3
      Top             =   4440
      Width           =   390
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   315
      Left            =   240
      TabIndex        =   2
      Top             =   4320
      Width           =   180
   End
   Begin VB.Menu tool 
      Caption         =   "工具"
      Begin VB.Menu find 
         Caption         =   "查找"
      End
   End
   Begin VB.Menu about 
      Caption         =   "关于"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Private Declare Function SendMessageLong Lib _
                         "user32" Alias "SendMessageA" _
                        ( _
                         ByVal hwnd As Long, _
                         ByVal wMsg As Long, _
                         ByVal wParam As Long, _
                         ByVal lParam As Long _
                        ) As Long
Private Const EM_GETLINECOUNT = &HBA

Function update()
Dim lineCount As Integer
lineCount = SendMessageLong(Text2.hwnd, _
               EM_GETLINECOUNT, 0&, 0&)
Label1.Caption = "共" & lineCount & "行" & Len(Trim(Text2.Text)) & "字"
txtlengh = Len(Text2.Text)
Text2.SelStart = txtlengh + 1
Text2.SelLength = 0
End Function
Function writedate()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(App.Path + "\Diary.diary", True)
a.Write Text2.Text & vbCrLf & Date & "     " & Time() & "        " & Combo1.Text
a.Close
End Function

Function writefile()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(App.Path + "\Diary.diary", True)
a.Write Text2.Text & vbCrLf & "      " & Text1(1).Text
a.Close
End Function

Function readfile()
Dim txtlengh As Long
Dim search As String, where As String
Const ForReading = 1
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(App.Path + "\Diary.diary", 1, -2)
Text2.Text = a.readall
a.Close
End Function

Private Sub about_Click()
frmSplash.Show
End Sub

Private Sub Command1_Click()
writedate
readfile
update
End Sub

Private Sub Command2_Click()
writefile
readfile
update
End Sub

Private Sub Command3_Click()
Dim i As Long
On Error GoTo errhandle:
i = InStr(Text2.Text, Text3.Text)
Text2.SelStart = i - 1
Text2.SelLength = Len(Text3.Text)
Exit Sub
errhandle: Label2.Caption = "查无结果,请确认日记中有所查内容"
End Sub

Private Sub find_Click()
Dim i As Long
i = InStr(Text2.Text, Text3.Text)
Text2.SelStart = i
Text2.SelLength = Len(Text3.Text)
End Sub

Private Sub Form_Activate()
update
End Sub

Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(App.Path + "/Diary.diary") = False Then
'Set fs = CreateObject("Scripting.FileSystemObject")
Set a1 = fs.CreateTextFile(App.Path + "\Diary.diary", True)
a1.WriteLine (Now())
a1.WriteLine (Time())
a1.WriteLine ("今天是你第一次使用该日记本。")
a1.WriteLine ("Tiancao 感谢你的支持")
a1.Close
End If
readfile
Label3.Caption = Now()
OpenPassword = LoadResString(101)
EditPassword = LoadResString(102)
End Sub

Private Sub Timer1_Timer()
Label3.Caption = Now()
End Sub

⌨️ 快捷键说明

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