VB如何读取文本文件里的内容?内容如下?

[SqlServer]User Id=saPassword=Initial Catalog=GsqsyData Source=192.168.1.192
2024-12-25 07:13:09
推荐回答(1个)
回答1:

Dim UserId, Password, InitialCatalog, DataSource
Set FSO = CreateObject("Scripting.FileSystemObject")
s = FSO.OpenTextFile("a.txt", 1).ReadAll
UserId = Split(Split(s, vbCrLf & "User Id=")(1), vbCrLf)(0)
Password = Split(Split(s, vbCrLf & "Password=")(1), vbCrLf)(0)
InitialCatalog = Split(Split(s, vbCrLf & "Initial Catalog=")(1), vbCrLf)(0)
DataSource = Split(Split(s, vbCrLf & "Data Source=")(1), vbCrLf)(0)