Results 1 to 2 of 2

Thread: Help me!!! Visual Basic programmers needed

  1. #1
    Member
    Join Date
    Jun 2009
    Location
    Puerto Rico
    Posts
    183
    Thanks
    75
    Thanked 16 Times in 12 Posts

    [SOLVED] Help me!!! Visual Basic programmers needed

    Hello there. I am doing an update for my software, PerfectCompress. The program launches exe files to compress a file, for example, if the user is going to compress to PAQ8PX, the software will open paq8px.exe. The problem is that these opens in a command line window. I have found this code to redirect the command line window to a RichTextBox, however, the software does not ends and it is supposed to end. I have a looping process so the software can update the RichTextBox but when the compression finish, the RichTextbox just writes blank lines and do not end the compression software.

    The code is as follows:
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim PAQExe As String = "paq8px_v60.exe"
            Dim PAQDir As String = ""
    
            Dim PAQ As New ProcessStartInfo
            Dim StartPAQ As Process
            Dim sLine As String
    
            PAQ.WorkingDirectory = PAQDir
            PAQ.FileName = PAQExe
            PAQ.Arguments = "-5 """ & TextBox2.Text & """ """ & TextBox1.Text & """"
            PAQ.UseShellExecute = False 'required to redirect
            PAQ.RedirectStandardInput = True
            PAQ.RedirectStandardOutput = True
            PAQ.CreateNoWindow = True 'creates no cmd window
    
            Try
                StartPAQ = Process.Start(PAQ)
                Do
                    sLine = StartPAQ.StandardOutput.ReadLine
                    RichTextBox1.Text += sLine & vbNewLine
                    RichTextBox1.Refresh()
                Loop
                StartPAQ.WaitForExit()
            Catch ex As Exception
                RichTextBox1.AppendText(ex.Message)
            End Try
        End Sub
    End Class
    Please help me. I write this because I don't want Command prompt windows to pop-up. Instead, I want everithing to be displayed on the program RichTextBox.
    Last edited by moisesmcardona; 27th June 2009 at 21:47.

  2. #2
    Member
    Join Date
    Jun 2009
    Location
    Puerto Rico
    Posts
    183
    Thanks
    75
    Thanked 16 Times in 12 Posts
    never mind. I got the code to work.

    here is the working code:
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim Server_Exe As String = "paq8px_v60"
            Dim Server_Dir As String = ""
    
            Dim Server As New ProcessStartInfo
            Dim StartServer As Process
            Dim sLine As String
    
            Server.WorkingDirectory = Server_Dir
            Server.FileName = Server_Exe
            Server.Arguments = "-5 test5678 123"
            Server.UseShellExecute = False 'required to redirect
            Server.RedirectStandardInput = True
            Server.RedirectStandardOutput = True
            Server.CreateNoWindow = True 'creates no cmd window
    
            Try
                StartServer = Process.Start(Server)
                Do While StartServer.HasExited = False
                    sLine = StartServer.StandardOutput.ReadLine
                    RichTextBox1.Text += sLine & vbNewLine
                    RichTextBox1.Refresh()
                    RichTextBox1.SelectionStart = RichTextBox1.Text.Length
                    RichTextBox1.ScrollToCaret()
                Loop
                StartServer.WaitForExit()
                MsgBox("Compression success")
            Catch ex As Exception
                RichTextBox1.AppendText(ex.Message)
            End Try
    
        End Sub
    
    End Class

Similar Threads

  1. Slow Visual 2010
    By Cyan in forum The Off-Topic Lounge
    Replies: 23
    Last Post: 24th May 2010, 03:03
  2. CLI memory teste needed
    By SvenBent in forum The Off-Topic Lounge
    Replies: 7
    Last Post: 21st April 2010, 09:06
  3. paq7asmsse -> GAS (uses CPUID), no .CPP changes needed
    By Rugxulo in forum Data Compression
    Replies: 8
    Last Post: 22nd December 2009, 12:58
  4. Precomp Help needed please
    By Rusty_v in forum Data Compression
    Replies: 2
    Last Post: 8th July 2009, 18:16
  5. [OFFTOPIC]: Problem for hardcore programmers!
    By nimdamsk in forum Forum Archive
    Replies: 4
    Last Post: 25th March 2007, 19:12

Posting Permissions

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