# Re: VB 写类似Config.sys格式档案

Posted by 我依然是小呆瓜 on March 27, 1999 at 19:36:48:

In Reply to: VB 写类似Config.sys格式档案 posted by 新手 on March 25, 1999 at 20:12:12:

: 请问Config.sys或System.ini这种格式的程式如何写?如何读和写档案内所想要之某一行资料? 谢谢!

Config,sys与System.ini与*.txt一样，都是纯文书格式
如存档..
Dim A As String, B As String, C As String, D As String, E As String, F As String
A="[Postion]"
B="X=100"
C="Y=250"
D="Z=-250"
E="[User]"
F="Name=stupids"
G="Age=22"

Fn= FreeFile
Open "stupids.ini" For Output As #Fn
Print #Fn ,A
Print #Fn ,B
Print #Fn ,C
Print #Fn ,D
Print #Fn ,E
Print #Fn ,F
Print #Fn ,G
Close #Fn

如读档要读出Name的资讯
Dim Tmp As String
Dim MyName As String
Fn=FreeFile
Open "stupids.ini" For Input As #Fn
Do Until Eof(Fn)
Line Input #Fn, Tmp
If UCase(Left( Trim(Tmp),5))="NAME=" Then MyName = Trim(Right(Tmp,Len(Tmp)-5))
Loop
Close #Fn

Follow Ups: