0
我當前的代碼要求我在項目仍然在VB時編輯搜索值。我一直無法弄清楚如何編碼輸入值來使用文本框進行搜索。我真的很想能夠構建這個項目並在不打開VB的情況下使用它。以下是我的代碼:爲十六進制值創建一個搜索欄
Dim filePath As String = Me.TextBox1.Text 'The path for the file you want to search
Dim fInfo As New FileInfo("C:\MyFile.File")
Dim numBytes As Long = fInfo.Length
Dim fStream As New FileStream("C:\MyFile.File", FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fStream)
Dim data As Byte() = br.ReadBytes(CInt(numBytes))
Dim pos As Integer = -1
Dim searchItem As String = "b6" 'The hex values of what you want to search
Dim searchItemAsInteger As Integer
Dim locationsFound As New List(Of Integer)
MessageBox.Show("Wait while I Scan?")
br.Close()
fStream.Close()
Integer.TryParse(searchItem, Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, searchItemAsInteger)
For Each byteItem As Byte In data
pos += 1
If CInt(byteItem) = searchItemAsInteger Then
locationsFound.Add(pos)
Me.ListBox1.Items.Add(Hex(pos))
End If
Next
For i As Integer = 0 To Me.ListBox1.Items.Count - 1
Me.ListBox1.SetSelected(i, True)
Next
End Sub
兩點:「我真的很希望能夠建立這個項目,並使用它,而無需打開VB」 VB.net創建與每一個.exe建立在調試文件夾。你可以在沒有Visual Studio的情況下運行。 「一直未能弄清楚如何編碼輸入值以使用文本框進行搜索」輸入值是什麼?我對你的目標感到困惑,你的問題是什麼。你能詳細說明一下嗎? – Kat 2014-10-29 16:05:38
我的應用程序沒有搜索欄。我不得不編輯我的代碼中的搜索值,並調試才能使用它。因此要求我打開VB以輸入和搜索下一個值。上面的代碼返回一個偏移量列表,表示我在文件中的值。 – King96 2014-10-29 16:35:07
我想使用文本框來搜索「b6」而不是在我的代碼中 – King96 2014-10-29 16:36:33