vb.net - 在文件中搜索特定字符串
问题描述
我正在编写一个程序,该程序将能够搜索多个文件并在其中编辑特定字符串并将其保存回原来的位置。
目前我拥有它,因此它可以搜索文件并将其显示在富文本框中。
告诉我文件中有多少行并编辑文件中与特定文本相反的特定行,你们中的任何人都可以帮助我吗?
Public Class Form1
Dim Int1 As Integer
Dim Reader As StreamReader
Dim Lines As String = Int1
Dim Path As String = "C:\Users\callum.hirst\Desktop\DNS\burnsrecruitment.co.uk.dns"
Dim Content As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Int1 = New Integer
Reader = File.OpenText(Path)
Dim someString As String = "@ 3600 NS nameserver2.i7net.co.uk." 'this Textbox for searching text example : Yellow
Dim lines() As String = File.ReadAllLines(Path)
Dim found As Integer = -1
Dim i As Integer
For i = 0 To lines.Length - 1 Step i + 1
If lines(i).Contains(someString) Then
found = i
Int1 = i
MsgBox(Int1)
Exit For
End If
Next
Reader = File.OpenText(Path)
End Sub
End Class
解决方案
推荐阅读
- r - read_csv (readr, R) 如果在简单而干净的 csv 中存在 NA 1000 + x 个观察值,则用 NA 填充整个列(解析失败)
- react-native - 如何在 React-Native 中刷新 FlatList 中的单个项目?
- react-native - React Navigation:透明标题没有高度
- javascript - 从另一个数组中对对象键数组进行排序
- google-cloud-platform - 在 Google 部署管理器中部署 IAM 角色时出错
- xamarin.ios - UIScrollView Xamarin Ios
- java - “每个测试方法一个对象”的 Spring bean 范围
- javascript - 如何使用 Web Audio API 调整麦克风灵敏度 [不是音量]
- python - TypeError:'cmp' 是此函数的无效关键字参数-Python
- java - Install4j:向系统托盘添加服务图标