你可以考虑做成INI文件,格式
[SECTION] GC120=10211 GC119=12111 GC121=12112 GC122=12113 GC123=12114
然后用API函数读取.
VB读取INI文件程序:
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 Function ReadIni(ByVal file As String, ByVal section As String, _ ByVal key As String, ByVal default As String) As String Dim x As Long Dim sSection As String, sEntry As String, sDefault As String Dim sRetBuf As String, iLenBuf As Integer, sFileName As String 'Six arguments sSection$ = section sEntry$ = key sDefault$ = default sRetBuf$ = String$(256, 0) '256 null character iLenBuf% = Len(sRetBuf$) sFileName$ = file 'function will return a value of 12 in this case x = GetPrivateProfileString(sSection$, sEntry$, sDefault$, sRetBuf$, iLenBuf%, sFileName$) 'sValue$ will contain the string 'PACKARD BELL' sValue$ = Left$(sRetBuf$, x) 'return value ReadIni = sValue$ End Function
Sub Test_ReadIni() MsgBox ReadIni("d:\test.ini", "TEST", "2", "null") End Sub
文件d:\test.ini的内容:
[test] 1=hello 2=world 3=! |