📄 frmtip.frm
字号:
VERSION 5.00
Begin VB.Form frmTip
BorderStyle = 1 'Fixed Single
Caption = "日积月累"
ClientHeight = 3555
ClientLeft = 2355
ClientTop = 2385
ClientWidth = 6285
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3555
ScaleWidth = 6285
WhatsThisButton = -1 'True
WhatsThisHelp = -1 'True
Begin VB.CheckBox chkLoadTipsAtStartup
Caption = "启动时显示(&S)"
Height = 180
Left = 120
TabIndex = 3
Top = 3255
Width = 2055
End
Begin VB.CommandButton cmdNextTip
Height = 375
Left = 5025
Style = 1 'Graphical
TabIndex = 2
Top = 600
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.PictureBox Picture1
BackColor = &H80000018&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3030
Left = 120
Picture = "frmTip.frx":0000
ScaleHeight = 2970
ScaleWidth = 4725
TabIndex = 1
Top = 105
Width = 4785
Begin VB.Label Label1
BackColor = &H80000018&
Caption = "您知道吗?"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 540
TabIndex = 5
Top = 180
Width = 2655
End
Begin VB.Label lblTipText
BackColor = &H00FFFFFF&
BackStyle = 0 'Transparent
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2280
Left = 180
TabIndex = 4
Top = 735
Width = 4500
End
End
Begin VB.CommandButton cmdOK
Cancel = -1 'True
Default = -1 'True
Height = 375
Left = 5010
Style = 1 'Graphical
TabIndex = 0
Top = 120
UseMaskColor = -1 'True
Width = 1215
End
End
Attribute VB_Name = "frmTip"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' 技巧的数据库。
Dim Tips As New Collection
' 技巧文件名称。
Const TIP_FILE = "TIPOFDAY.TXT"
' 当前被显示的技巧集合索引。
Dim CurrentTip As Long
Dim lngOldTip As Long
Private Sub DoNextTip()
' 随机选择一个技巧。
lngOldTip = CurrentTip
Do Until CurrentTip <> lngOldTip
CurrentTip = Int((Tips.Count * Rnd) + 1)
Loop
' 或者,按顺序在所有技巧中循环选择。
' CurrentTip = CurrentTip + 1
' If Tips.Count < CurrentTip Then
' CurrentTip = 1
' End If
' 显示。
frmTip.DisplayCurrentTip
End Sub
Function LoadTips(sFile As String) As Boolean
Dim NextTip As String ' 从文件读取每一个技巧。
Dim InFile As Integer ' 文件描述符。
' 获得下一个空文件描述符。
InFile = FreeFile
' 确保一个文件被指定。
If sFile = "" Then
LoadTips = False
Exit Function
End If
' 试图打开一个文件前,确保该文件存在。
If Dir(sFile) = "" Then
LoadTips = False
Exit Function
End If
' 从文本文件读取该集合。
Open sFile For Input As InFile
While Not EOF(InFile)
Line Input #InFile, NextTip
If Trim(NextTip) <> "" Then
Tips.Add NextTip
End If
Wend
Close InFile
' 随机显示一个技巧。
DoNextTip
LoadTips = True
End Function
Private Sub chkLoadTipsAtStartup_Click()
' 保存启动时该窗体是否显示。
SaveSetting App.title, "Tips", "ShowWhenStart", chkLoadTipsAtStartup.Value
End Sub
Private Sub cmdNextTip_Click()
DoNextTip
End Sub
Private Sub cmdOK_Click()
Set Tips = Nothing
Unload Me
End Sub
Private Sub Form_Load()
' 设置复选框
Me.chkLoadTipsAtStartup.Value = GetSetting(App.title, "Tips", "ShowWhenStart", 1)
' 为 Rnd 重置种子
Randomize
' 读技巧文件并随机显示一个技巧。
If LoadTips(App.Path & "\" & TIP_FILE) = False Then
cmdNextTip.Enabled = False
lblTipText.Caption = "" & TIP_FILE & " 文件未找到?" & vbCrLf & vbCrLf & _
"使用记事本,创建一个名为 " & TIP_FILE & " 的文本文件,其中每行一个技巧。 " & _
"然后,放在应用程序所在目录下。"
End If
Set Me.Icon = Utility.GetFormResPicture(139, vbResIcon)
Set cmdOk.Picture = GetFormResPicture(1001, 0)
Set cmdNextTip.Picture = GetFormResPicture(1004, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
RemoveFormResPicture 1001
RemoveFormResPicture 1004
RemoveFormResPicture 139
End Sub
Public Sub DisplayCurrentTip()
Dim strTemp As String
Dim strTemp1 As String
If Tips.Count > 0 Then
strTemp = GetNoXString(Tips.Item(CurrentTip), 1, ":")
If Len(strTemp) > 0 And Len(strTemp) < Len(Tips.Item(CurrentTip)) Then
strTemp1 = Right(Tips.Item(CurrentTip), Len(Tips.Item(CurrentTip)) - Len(strTemp) - 1)
strTemp = strTemp & Chr(13) & " " & strTemp1
End If
lblTipText.Caption = strTemp 'Tips.Item(CurrentTip)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -