All pastes #741755 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-18 23:10 UTC
rendered paste body
' the goal here is to have a text box that accepts return and the user to type in the command and hit "ENTER" and it executes the command on the server
' after the command is executed it should display the stdout to the txtLog window.
' i'm not sure what exactly i am doing wrong but much appreciation to anyone that will help me understand the easiest possible way to succeed in this.

' ERROR when "ENTER" key is pressed: Object reference not set to an instance of an object 

Protected WithEvents stdout As nsoftware.IPWorksSSH.SshellStdoutEventArgs



    Private Sub txtCmd_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCmd.KeyPress
        Dim stdout As nsoftware.IPWorksSSH.SshellStdoutEventArgs
        stdout = New nsoftware.IPWorksSSH.SshellStdoutEventArgs

        If e.KeyChar = Chr(13) Then
            If Ssh.Connected = True Then
                If txtCmd.Focused = True Then
                    Try
                        Ssh.Execute(txtCmd.Text)
                        txtLog.AppendText(stdout.Text & vbCrLf)
                    Catch err As Exception
                        txtLog.AppendText(err.Message)
                    End Try
                End If
            End If
        End If
    End Sub