永发信息网

大家来帮我看下这个VB读写ini文件的类模块

答案:1  悬赏:0  手机版
解决时间 2021-05-14 18:30

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子程序或函数未定义啊?

最佳答案

我有个成熟的INI读写类,可以发给你。

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
为什么彩虹岛都是连接失败
能把吸血鬼日记的中文版下载地址给我吗
梦幻西游宠物店赚钱吗,梦幻西游手游牧场怎么
谁有金麟的书的地址
铁锋区联邦发型地址有谁知道?有点事想过去
长城捷豹摩托车机油在镇江怎么买?
动漫大神们!帮忙喽。
京华数码 PMP-1700的MP4为什么视频下进去总是
和教师有关的诗歌,关于赞美老师的优美句子。
什么样的卷发可以让你看起来比较淑女?
阳历1984年7月15日是什么星座
QQ飞车两人三开刷末日逃亡模式,有系统八倍经
小游戏源码 .net版
天元区株洲森森水族连锁店no.湘02-05地址在什
谁知道绿光森林(LALA版)的空间歌曲地址
推荐资讯
新洲区壹哆康鼻腔护理中心这个地址怎么能查询
现在哪家银行的贷款利息低?
什么是热机效率
怎么把QQ的各个聊天窗口合成一个,便于管理?
手机绑定图标如何熄灭
荆州区城南街道办事处御河居委会委员会怎么去
樊城区襄阳市文化宫职工米公祠翘园书画培训在
珠晖区双水湾老磨坊地址在哪里啊
请问这个网站是做什么的?
华龙区濮阳高新区昆吾街道办事处哪位知道具体
东西卸不去啊
YY怎么玩???
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?