第1个回答 2010-08-06
Private Sub Command1_Click()
Open "d:\1.ini" For Input As #1
Do
Line Input #1, a
If a = "[" & Text1.Text & "]" Then
Print a
Do
Line Input #1, a
Print a
Loop Until a = ""
End If
Loop Until EOF(1)
Close (1)
End Sub
Private Sub Form_Load()
Dim a
End Sub本回答被提问者采纳
第2个回答 2010-08-09
可以调用以下两个API函数来很方便地读/写ini文件:
GetPrivateProfileString
WritePrivateProfileString
两个函数的定义分别如下:
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
将以上定义写在模块开头,就可以象VB的内部函数一样使用了。