Attribute VB_Name = "modPub"
Option Explicit
Public strAppPath$
Public intFontSize As Integer
Public strFontColor As String
Public lngFontColor As Long
Public strSplit As String
Sub Main()
strAppPath = App.Path
If Right(strAppPath, 1) <> "\" Then strAppPath = strAppPath & "\"
iniFileName = strAppPath & "user.INI"
If Dir(iniFileName) <> "" Then
Call initFromIniFile
Else
Call initFromApp
Call saveToIniFile
End If
Form1.Show
End Sub
'从配置文件初始化
Private Sub initFromIniFile()
' On Error GoTo err1
intFontSize = Trim(GetIniS("UserSet", "FontSize"))
strFontColor = Trim(GetIniS("UserSet", "FontColor"))
lngFontColor = Val(strFontColor)
strSplit = Trim(GetIniS("UserSet", "Split "))
Exit Sub
err1:
Call initFromApp
Call saveToIniFile
End Sub
'保存到配置文件
Public Sub saveToIniFile()
SetIniS "UserSet", "FontSize", CStr(intFontSize)
SetIniS "UserSet", "FontColor", CStr(strFontColor)
SetIniS "UserSet", "Split", CStr(strSplit)
End Sub
'用程序自身初始化
Private Sub initFromApp()
intFontSize = 10
strFontColor = "&HFFFF&"
lngFontColor = Val(strFontColor)
strSplit = "---------------------------------"
End Sub