谢谢楼上两位的指点!在两位的指点下,我用如下代码达到了要求:
如果"c:\hzw.ini"的内容如下:
=加一条数据1
=加一条数据2
=加一条数据3
=加一条数据
------------------------------
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
Private Sub Form_Load()
Dim myStr$, mStr(), i%
myStr = "加一条数据"
Open "c:\hzw.ini" For Input As #1
Do While Not EOF(1)
ReDim Preserve mStr(i)
Line Input #1, mStr(i)
i = i + 1
Loop
Close #1
For i = 0 To UBound(mStr)
If Split(mStr(i), "=")(1) = myStr Then Exit Sub
Next i
WritePrivateProfileString App.Title, "", myStr, "c:\hzw.ini"
End Sub