VB6.0读取配置文件 - 洛阳翼展电脑


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
0

发表评论:

VirtualCamera:在录像机中虚拟一个通道显示电脑桌面、视频文件、USB摄像头~
预ICP备10086-001号 © 翼展网/80C.CC 技术支持/洛阳翼展科技
TEL / 13213610060 QQ / 345794501
Powered by emlog