VB6.0读取配置文件
2024-1-17 乱云飞
Private Sub Command1_Click() Dim fileContent As String ' 调用函数并获取文件内容 fileContent = ReadLine("1.conf", 5) ' 显示指定行数的内容 If fileContent <> "" Then Label1.Caption = fileContent MsgBox fileContent Else MsgBox "文件内容不足指定行数" End If End Sub Private Function ReadLine(filePath As String, lineNumber As Integer) As String Dim fileContent As String ' 打开文件并读取指定行数的内容 With CreateObject("Scripting.FileSystemObject").OpenTextFile(filePath) For i = 1 To lineNumber fileContent = .ReadLine Next i .Close End With ' 返回指定行数的内容 ReadLine = fileContent End Function本文链接:http://80c.cc/ez/747.html
发表评论: