Private Declare Function GetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpfilename As String) As Long
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, lpfilename As String) As Long
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String, lpfilename As String) As Long
Private iniFileName As String
Public ERRmsg As String
Private Sub class_initialize()
iniFileName = "C:\Users\zj\Documents\vb资料\zidongguanji.ini"
ERRmsg = vbNullString
End Sub
Public Sub specifyini(FilePathName)
iniFileName = Trim(FilePathName)
End Sub
Private Function noinifile() As Boolean
noinifile = True
If iniFileName = vbNullString Then
ERRmsg = "没有找到ini文件"
Exit Function
End If
ERRmsg = vbNullString
noinifile = False
End Function
Public Function writestring(section As String, key As String, value As String) As Boolean
writestring = False
If noinifile = True Then
Exit Function
End If
If WriteProfileString(section, key, value, iniFileName) = 0 Then
ERRmsg = "写入INI文件失败"
End If
writestring = True
End Function
Public Function Readstring(section As String, key As String, size As Long) As String
Dim returnstring As String
Readstring = vbNullString
If noinifile = True Then
Exit Function
End If
returnstring = Space(size)
GetProfileString section, key, vbNullString, returnstring, size, iniFileName
Readstring = Trim(returnstring)
End Function
Public Function ReadInt(section As String, key As String) As Long
Dim returnlng As Long
ReadInt = 0
If noinifile = True Then
Exit Function
End If
returnlng = GetProfileInt(section, key, 0, iniFileName)
If returnlng = 0 Then
returnlng = GetProfileInt(section, key, 1, iniFileName)
If returnlng = 1 Then
ERRmsg = "不能读取"
Exit Function
End If
End If
ReadInt = returnlng
End Function
这模块有错吗?
没有错为什么我在工程引用的时候老是提示ReadString子程序或函数未定义啊?