View Single Post
  #74  
Old 05-07-2015, 11:37 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi emexy,

I am glad to hear that you found a way to filter out the unwanted string. You could modify your approach to remove the unwanted string and the blank line. For example:
strResult = Replace(strResult, vbcrlf & "{master:0}" , "")
strResult = Replace(strResult, vbcrlf & "{master:1}" , "")
strResult = Replace(strResult, vbcrlf & vbcrlf, vbcrlf)
To parse the output, you could use something similar to the following:
Code:
strResult = Replace(strResult, vbcrlf & "{master:0}" , "")
strResult = Replace(strResult, vbcrlf & "{master:1}" , "")
strResult = Replace(strResult, vbcrlf & vbcrlf, vbcrlf)
strVlanReport = ""
' Create an array of the results that we can iterate over.
vLines = Split(strResult, vbcrlf)
' Iterate over the array
For Each strLine in vLines
    ' Find out if the line has a space. If it does capture the location.
    nPos = Instr(strLine, " ")
    ' If a space is found, capture the data left of the space.
    If nPos > 0 Then
        strVlanReport = strVlanReport & vbcrlf & Left(strLine, nPos - 1)
    End If
Next
strResult = strVlanReport
Does this help you accomplish your goal?

As a note, if you are running other commands, you will likely want to only run the code above if the command is sh vlans.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote