VB编程之如何提取记事本中某行的内容,下面来看具体代码。对一个按钮编程,点击一下,就可以实现读取记事本某行内容的功能。
先看读取第一行的内容文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html
[code]Private Sub Command1_Click()
Open texturl For Input As #1
Dim txt As String
Line Input #1, txt
Debug.Print txt
Close #1
End Sub文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html
[/code]文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html
假设要提取文本地址为texturl中行数为i行的内容文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html
[code]
Private Sub Command1_Click()
Open texturl For Input As #1
Dim txt As String
Dim n As Integer
n = 1
Do While n <= i
Line Input #1, txt
n = n + 1
Loop
'现在txt就是所求的文本
Debug.Print txt
Close #1
End Sub
[/code]文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html
看似很简单的功能,有些场合我们会用到,发在这里当作备忘录用吧。文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html 文章源自公式库网-https://www.gongshiku.com/html/202003/vbbianchengzhiruheanxingtiqujishibenzhongdeneirong.html