module1.bas
来自「VB读INI类型的文件」· BAS 代码 · 共 30 行
BAS
30 行
Attribute VB_Name = "Module1"
Option Explicit
Public 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
Public 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
Public 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
'ipappplicationname 字段名
'ipkeyname 关键字
'ipfilname INI文件名
Public Function GetINI(ByRef inifile As String, ByVal section As String, ByVal key As String, Optional ByVal defvalue As String = vbNullString) As String
'inifile INI文件名, section 段落,key 关键字,defvalue 值
Dim sTemp As String * 256
Dim nLen As Integer
sTemp = Space$(256)
nLen = GetPrivateProfileString(section, key, defvalue, sTemp, 255, App.Path & inifile)
GetINI = Left$(sTemp, nLen)
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?