vb.net help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blastman
    New Member
    • Sep 2007
    • 3

    vb.net help

    hey all,

    I'v writed some code (below) that runs a batch file and i'm trying to direct the output to a form called formstatus. On this form there is a list box (so as to make it scrollable) in which i'd like the batch file output to be displayed.

    firstly, the bold underlined line throws an error "value cannot be null, parameter name: item" since i'm new to this and lerning as i go i have no idea how to correct it!!

    secondly, Once that error is cleared am i write in thinking that the listbox will show all of the outputed display but only after it has completed? Is there a way to make to update "live" so i could see each line displayed as it's beening run in the batch file?

    cheers in advance.
    Code:
    Imports system.io
    
    Public Class formtest
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testrun.Click
    
            'writes box1.text to a txt file for go.bat to import
            Shell("c:\2go.bat " + box1.Text)
            ' Set start information.
            Dim start_info As New ProcessStartInfo("c:\go.bat")
            start_info.UseShellExecute = False
            start_info.CreateNoWindow = True
            start_info.RedirectStandardOutput = True
            start_info.RedirectStandardError = True
    
            ' Make the process and set its start information.
            Dim proc As New Process()
            proc.StartInfo = start_info
    
            ' Start the process.
            proc.Start()
    
            ' Attach to stdout and stderr.
            Dim std_out As StreamReader = proc.StandardOutput()
            Dim std_err As StreamReader = proc.StandardError()
    
            ' Display the results.
            Dim i As Integer
    
            For i = 0 To 15    ' 0 to <number of lines>
                Formstatus.Show()
                [B]Formstatus.Status.Items.Add(std_out.ReadLine)[/B]
            Next i
    
            Me.Close()
            
            ' Clean up.
            std_out.Close()
            std_err.Close()
            proc.Close()
        End Sub
    
    
    End Class
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET forum .

    Comment

    Working...