I seem to be able to find words pretty easily using regex, but I have never had to just use the first word of a line before.
The text file looks like this:
List of devices attached
80A004402340333503 device
0123456789ABCDEF device
what I want it to do is to save 80A004402340333503 as device1 and 0123456789ABCDEF as device2
so far I have this:
If CheckBox4.Checked = True Then
file = My.Computer.FileSystem.OpenTextFileWriter("c:\devices.bat", False)
file.WriteLine("@echo off")
file.WriteLine("cd " & TextBox2.Text)
file.WriteLine("adb devices > C:\devices.txt")
file.Close()
Shell("C:\devices.bat", AppWinStyle.Hide, True, 500)
Dim devicelines() As String = IO.File.ReadAllLines("C:\devices.txt")
Dim device1 As String = devicelines(1).First
Dim device2 As String = devicelines(1).First
End If
Obviously this doesnt quite work the way I had hoped, but if you could give me a hand in picking the first word in both the 2nd and 3rd line it would be greatly appreciated.
Thans
A String is just an array of characters.. so when you ask for String.First, you are asking for the first character. What you need to do is split the string into words and then get the first word.
Something like: