Results 1 to 5 of 5

Thread: [Resolved] Why is this code not working?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    [Resolved] Why is this code not working?

    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:

    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
    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.

    Does anyone know why this is???
    Last edited by Slyke; Oct 10th, 2007 at 11:32 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width