This is really only seeking an opinion.
I have two ways of getting the data I want ( being whatever is to the left of the first space ).
validInterface = Left(clipArray(t - 1), InStr(1, clipArray(t - 1), " ") - 1)
OR
validInterface = Split(clipArray(t - 1), " ")(0)
These both will return exactly what I need. Tho, the first way will give me an error if there is no " " in the string.
In the current data that I'm working with, there will always be a " " in the data and no leading space.
Here's another example, showing why I like 'Split...()(#)' more.
Imagine a line of text from a router config that has an ip address, that looks like: " ip address 192.168.0.25 255.255.255"
So:
strAddresslLine = " ip address 192.168.0.25 255.255.255.0" ' Which would have the leading space
strIP = Split(Trim(strAddresslLine)," ")(2) ' The IP Address
strMASK = Split(Trim(strAddresslLine)," ")(3) ' The Netmask
Alternatively, I could have used the array completely:
arrAddressLine = Split(Trim(strAddresslLine)," ")
' arrAddressLine(0) would be "ip" - which I would never need
' arrAddressLine(1) would be "address" - also not needed
' arrAddressLine(2) would be "192.168.0.25"
' arrAddressLine(4) would be "255.255.255.0"
Beyond that, I could further Split(sIP,".") to get the IP pieces.
Which do you think is better (And why)?
Bookmarks