Vba能够通过读取ini文件控制控件的属性(大小、位置、字体、颜色、样式……)吗代码怎么写

Vba能够通过读取ini文件控制控件的属性(大小、位置、字体、颜色、样式……)吗代码怎么写,第1张

VBA必须通过调用WN32 API来实现INI文件的读写,把控件属性及其值在程序退出时写入INI文件,在程序加载时读取INI文件并设置控件属性
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 WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
'INI文件写
'参数:
'strSection:节名称
'strItem:项名称
'strValue:项的值
'strIniFile:INI文件
Private Function WriteIniFile(strSection,strItem,strValue,strIniFile) as Long
Dim lngWriteOk As Long
lngWriteOk = WritePrivateProfileString(strSection,strItem,strValue,strIniFile)
End Sub
'INI文件读
'参数:
'strSection:节名称
'strItem:项名称
'strDefValue:项的默认值
'strIniFile:INI文件
Private Function strReadIniFile(strSection,strItem,strDefValue,strIniFile) as String
Dim lngReadOk As Long
Dim strValue As String
Dim strReadValue As String
strValue=strDefValue
tmpReadValue = String(255, 0)
lngReadOk = GetPrivateProfileString(strSection, strItem, strDefValue, strReadValue, 256, strIniFile)
If lngReadOk then
strValue=trim(strReadValue)
end if
strReadIniFile=strValue
End Sub

以上就是关于Vba能够通过读取ini文件控制控件的属性(大小、位置、字体、颜色、样式……)吗代码怎么写全部的内容,包括:Vba能够通过读取ini文件控制控件的属性(大小、位置、字体、颜色、样式……)吗代码怎么写、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10127941.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存