📄 cpreferences.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CPreferences"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
' DataMonkey Data Conversion Application. Written by Theodore L. Ward
' Copyright (C) 2002 AstroComma Incorporated.
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
' The author may be contacted at:
' TheodoreWard@Hotmail.com or TheodoreWard@Yahoo.com
Option Explicit
Private mCol As New Collection
Public Function GetPreference(PrefName As String) As Variant
On Error Resume Next
GetPreference = ""
GetPreference = mCol(PrefName)
End Function
Public Sub SetPreference(PrefName As String, PrefVal As Variant)
On Error Resume Next
Dim newItem As CPreferenceItem
Set newItem = mCol(PrefName)
If newItem Is Nothing Then
Set newItem = New CPreferenceItem
mCol.Add item:=PrefVal, key:=PrefName
End If
newItem.name = PrefName
newItem.value = PrefVal
Set newItem = Nothing
End Sub
Public Sub DeletePreference(PrefName As String)
On Error Resume Next
mCol.Remove PrefName
End Sub
Public Function Load(arc As CArchive) As Boolean
On Error GoTo eHandler
Load = False
Dim item As String, value As Variant, retVal As ArcRetType
' Get and process the next line from the input file.
Do
retVal = arc.GetNextItem(item, value)
' Error, log it, then exit with error.
If retVal = ArcRetType.cERROR Then
arc.AddError
GoTo done
' We are done with this object, leave.
ElseIf retVal = ArcRetType.cENDITEM Then
Exit Do
End If
If Len(item) = 0 Then
arc.AddError
ElseIf retVal <> cBEGINITEM Then
' Add a new preference
SetPreference item, value
End If
Loop While Not retVal = cENDOFFILE
Load = True
done:
Exit Function
eHandler:
LogError "CPreferences", "Load", Error(Err), False
End Function
Public Function Save(arc As CArchive) As Boolean
On Error GoTo eHandler
Dim item As CPreferenceItem
Save = False
arc.SaveItem aiBEGINPREFERENCES, "Application Preferences"
For Each item In mCol
arc.SaveItem aiVALUE, item.name, item.value
Next item
arc.SaveItem aiENDITEM, "Application Preferences"
terminate:
Save = True
Exit Function
eHandler:
LogError "CPreferences", "Save", Error(Err), False
Exit Function
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -