I now know that \S means any non-whitespace, but how would i fit it into the sample code below please? I found out about the \S, but no where seems to discuss how to actually incorporate it into code.
I want to split each line of the array at each 'space' into separate words, but i dont want it to return 'space' as a results if theres a part that is 'doubled-spaced'. Which it is doing currently.
Private Sub ReadHosts()
Dim strReader As New System.IO.StreamReader("c:\windows\system32\drivers\etc\hosts_test")
Dim arrayChkdHost(1000, 3) As String
Dim arraySingleHost() As String, arrayIP$(100), arrayNS$(100), arrayOther$(100)
Dim HostLine As String
Dim i As Integer
'Clear ListBox
'Read in the hosts file line by line, breaking it down with string.split
i = 0
HostLine = strReader.ReadLine
Do While Not (HostLine Is Nothing)
arraySingleHost = HostLine.Split(" ")
arrayIP(i) = arraySingleHost(0)
arrayNS(i) = arraySingleHost(1)
arrayOther(i) = arraySingleHost(2)
MsgBox(arrayIP(i) + " = IP")
MsgBox(arrayNS(i) + " = NS")
MsgBox(arrayOther(i) + " = Other")
HostLine = strReader.ReadLine
i = i + 1
Loop
End Sub
Also in addition could someone please explain to me what the $ in : 'arrayIP$(100)', does please?
Thank you
I want to split each line of the array at each 'space' into separate words, but i dont want it to return 'space' as a results if theres a part that is 'doubled-spaced'. Which it is doing currently.
Private Sub ReadHosts()
Dim strReader As New System.IO.StreamReader("c:\windows\system32\drivers\etc\hosts_test")
Dim arrayChkdHost(1000, 3) As String
Dim arraySingleHost() As String, arrayIP$(100), arrayNS$(100), arrayOther$(100)
Dim HostLine As String
Dim i As Integer
'Clear ListBox
'Read in the hosts file line by line, breaking it down with string.split
i = 0
HostLine = strReader.ReadLine
Do While Not (HostLine Is Nothing)
arraySingleHost = HostLine.Split(" ")
arrayIP(i) = arraySingleHost(0)
arrayNS(i) = arraySingleHost(1)
arrayOther(i) = arraySingleHost(2)
MsgBox(arrayIP(i) + " = IP")
MsgBox(arrayNS(i) + " = NS")
MsgBox(arrayOther(i) + " = Other")
HostLine = strReader.ReadLine
i = i + 1
Loop
End Sub
Also in addition could someone please explain to me what the $ in : 'arrayIP$(100)', does please?
Thank you
Last edited: