[A] a="a" [B] b1="b1" b2="b2" [C] c1="c"Dim a, b1, b2, c1 As String '...... Dim tmp, strVarName, strValue As String Dim p As IntegerOpen "yourfile.ini" For Input As #1 Do Until EOF(1) Line Input #1, tmp p = InStr(1, tmp, "=") If p > 0 Then strVarName = Trim(Left(tmp, p - 1)) p = InStr(1, tmp, """) strValue = Mid(tmp, p + 1, InStr(p, tmp, """) - p) Select Case strVarName Case "a" a = strValue Case "b1" b1 = strValue Case "b2" b2 = strValue Case "c1" b1 = strValue '...... End Select End If Loop
a="a"
[B]
b1="b1"
b2="b2"
[C]
c1="c"Dim a, b1, b2, c1 As String
'......
Dim tmp, strVarName, strValue As String
Dim p As IntegerOpen "yourfile.ini" For Input As #1
Do Until EOF(1)
Line Input #1, tmp
p = InStr(1, tmp, "=")
If p > 0 Then
strVarName = Trim(Left(tmp, p - 1))
p = InStr(1, tmp, """)
strValue = Mid(tmp, p + 1, InStr(p, tmp, """) - p)
Select Case strVarName
Case "a"
a = strValue
Case "b1"
b1 = strValue
Case "b2"
b2 = strValue
Case "c1"
b1 = strValue
'......
End Select
End If
Loop
改用XML吧。或者将就ini用也可。