本论文在其他论文栏目,由论文格式网整理,转载请注明来源www.lwgsw.com,更多论文,请点论文格式范文查看
Case "/"
e = Str(Val(e) / Val(f))
f = ""
Case "^"
e = Str(Val(e) ^ Val(f))
f = ""
End Select
End Sub
二、提示信息模块相关代码:
Option Explicit
Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
' 内存中的提示数据库。
Dim Tips As New Collection
' 提示文件名称
Const TIP_FILE = "TIPOFDAY.TXT"
' 当前正在显示的提示集合的索引。
Dim CurrentTip As Long
Private Sub DoNextTip()
If Op1.Value = 1 Then
' 随机选择一条提示。
CurrentTip = Int((Tips.Count * Rnd) + 1)
Else
' 或者,您可以按顺序遍历提示
CurrentTip = CurrentTip + 1
If Tips.Count < CurrentTip Then
CurrentTip = 1
End If
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
Tips.Add NextTip
Wend
Close InFile
' 随机显示一条提示。
DoNextTip
LoadTips = True
End Function
Private Sub chkLoadTipsAtStartup_Click()
' 保存在下次启动时是否显示此窗体
SaveSetting App.EXEName, "Options", "在启动时显示提示", 1
End Sub
Private Sub cmdNextTip_Click()
DoNextTip
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim ShowAtStartup As Long, rtn
frmTip.Height = 4530
frmTip.Width = 4515
rtn = SetWindowPos(frmTip.hwnd, -1, 0, 0, 0, 0, 3)
' 察看在启动时是否将被显示
ShowAtStartup = GetSetting(App.EXEName, "Options", "在启动时显示提示", 1)
If ShowAtStartup = 0 Then
Unload Me
Exit Sub
End If
' 设置复选框,强行将值写回到注册表
'Me.chkLoadTipsAtStartup.Value = vbChecked
' 随机寻找
Randomize
' 读取提示文件并且随机显示一条提示。
If LoadTips(App.Path & "\" & TIP_FILE) = False Then
blTipText.Text = "文件 " & TIP_FILE & " 没有被找到吗? " & vbCrLf & vbCrLf & _
"创建文本文件名为 " & TIP_FILE & " 使用记事本每行写一条提示。 " & _
"然后将它存放在应用程序所在的目录 "
End If
End Sub
Private Sub Picture3_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Dim ReturnVal As Long
x = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Public Sub DisplayCurrentTip()
If Tips.Count > 0 Then
lblTipText.Text = Tips.Item(CurrentTip)
End If
End Sub