I'm trying to get a list of all the computers on my LAN. I have tried that huge long code that uses API calls and the such, but i want to stick with command prompt for this one (Simply because i may output it to a file later).
Well here's my code so far:
The problem (Bolded) for some reason only outputs the first computer name (I have about 4 on my network). In the WorkTxt text box has the 4 computers listed. Also if i comment out the bolded lines it will print all the lines from command prompt into the list box (One line per line). But for some reason, it doesn't like it when using the Left function to check whether there's two "\\" on the front of the line.Code:Private Sub CmdRefresh_Click() On Error Resume Next WorkTxt.Text = "" WorkTxt.Text = GetCommandOutput("net view") DoEvents Dim Computers_() As String Dim I_ As Integer Computers_ = Split(WorkTxt.Text, vbCrLf) For I_ = 0 To UBound(Computers_) If Not Left(Computers_(I_), 2) = "\\" Then RemoveItem Computers_(), I_ Next I_ For I_ = 0 To UBound(Computers_) ComputersList.AddItem Trim(Computers_(I_)) Next I_ End Sub Private Sub RemoveItem(sArray() As String, ByVal Index As Integer) Dim K As Integer If Index < UBound(sArray) Then For K = Index To UBound(sArray) - 1 sArray(K) = sArray(K + 1) Next K End If ReDim Preserve sArray(UBound(sArray) - 1) End Sub
Does anyone know why this is???




Reply With Quote