VB6 类模块,再引用另一个类模块的问题

superitman2006 2011-08-16 04:54:30
我做了一个通用INI处理的类,代码如下:
Option Explicit

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private IniFileName As String
Function GetIniS(ByVal SectionName As String, ByVal KeyWord As String, Optional ByVal DefString As String) As String
Dim ResultString As String * 144, Temp As Integer
Dim s As String, i As Integer

Temp% = GetPrivateProfileString(SectionName, KeyWord, "", ResultString, 144, IniFileName)

If Temp% > 0 Then
s = ""
For i = 1 To 144
If Asc(Mid$(ResultString, i, 1)) = 0 Then
Exit For
Else
s = s & Mid$(ResultString, i, 1)
End If
Next
Else
Temp% = WritePrivateProfileString(SectionName, KeyWord, DefString, IniFileName)
s = DefString
End If

GetIniS = s

End Function

Function GetIniN(ByVal SectionName As String, ByVal KeyWord As String, Optional ByVal DefValue As Integer) As Integer
Dim D As Long, s As String

D = DefValue
GetIniN = GetPrivateProfileInt(SectionName, KeyWord, DefValue, IniFileName)

If D <> DefValue Then
s = "" & D
D = WritePrivateProfileString(SectionName, KeyWord, s, IniFileName)
End If

End Function

Sub SetIniS(ByVal SectionName As String, ByVal KeyWord As String, ByVal ValStr As String)
Dim RES%

RES% = WritePrivateProfileString(SectionName, KeyWord, ValStr, IniFileName)

End Sub

Sub SetIniN(ByVal SectionName As String, ByVal KeyWord As String, ByVal ValInt As Integer)
Dim RES%, s$

s$ = Str$(ValInt)
RES% = WritePrivateProfileString(SectionName, KeyWord, s$, IniFileName)

End Sub
Public Property Get FileName() As Variant
FileName = IniFileName
End Property

Public Property Let FileName(ByVal vNewValue As Variant)
IniFileName = vNewValue
End Property

现在想再做一个,指定了文件名和属性的新类
比如说,我指定这个新类是在当前软件运行下的 VER.INI文件
有两个新的属性,
SoftVer 存取当前软件版本号
DataBaseVer 存取当前软件数据库版本号

请问大家如果用我已写好的类,写这个新的类呢?
...全文
169 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
superitman2006 2011-08-16
  • 打赏
  • 举报
回复
可以写个新类的代码吗?
在这个新类,指定它的私有属性是app.path & "\ver.ini"
新公有属性,softver
保存位置是ver,soft
新公有属性,databasever
保存位置是ver,database

然后我直接可以用这个类去读写当前版本
咸清 2011-08-16
  • 打赏
  • 举报
回复
加两个函数就是了

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧