Results 1 to 4 of 4

Thread: [RESOLVED] Shell CMD Text output format

  1. #1

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Resolved [RESOLVED] Shell CMD Text output format

    Hi there,

    Is it possible to get Multi-line text output from the command line into the TextBox and not all in one line?

    Used code:
    Code:
    Dim stCmdInText As String
     
     Dim objShell, objExecObject As Object
     
     stCmdInText = ""
    
     Set objShell = CreateObject("WScript.Shell")
     
     Set objExecObject = objShell.Exec("cmd /c ping -n 3 -w 1000 192.168.0.131")
     
     Do While Not objExecObject.StdOut.AtEndOfStream
      stCmdInText = stCmdInText & objExecObject.StdOut.ReadLine()
      Text1.Text = stCmdInText
      DoEvents
     Loop
    Output result:
    Name:  text.jpg
Views: 320
Size:  15.9 KB

    Thank you for your support!

  2. #2
    New Member
    Join Date
    Oct 2022
    Location
    Brazil
    Posts
    3

    Re: Shell CMD Text output format

    Hello!

    have you ever tried to concatenate "vbCrlf"?

    Code:
    Do While Not objExecObject.StdOut.AtEndOfStream
      stCmdInText = stCmdInText & objExecObject.StdOut.ReadLine() & vbCrlf
      Text1.Text = stCmdInText
      DoEvents
     Loop
    if this dont work try to concatenate VBNewLine

    Code:
    Do While Not objExecObject.StdOut.AtEndOfStream
      stCmdInText = stCmdInText & objExecObject.StdOut.ReadLine() & vbNewLine
      Text1.Text = stCmdInText
      DoEvents
     Loop
    hope it helps!!

  3. #3

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: Shell CMD Text output format

    Quote Originally Posted by Auguro View Post
    Hello!

    have you ever tried to concatenate "vbCrlf"?

    Code:
    Do While Not objExecObject.StdOut.AtEndOfStream
      stCmdInText = stCmdInText & objExecObject.StdOut.ReadLine() & vbCrlf
      Text1.Text = stCmdInText
      DoEvents
     Loop
    if this dont work try to concatenate VBNewLine

    Code:
    Do While Not objExecObject.StdOut.AtEndOfStream
      stCmdInText = stCmdInText & objExecObject.StdOut.ReadLine() & vbNewLine
      Text1.Text = stCmdInText
      DoEvents
     Loop
    hope it helps!!
    OMG, Thanks a lot! It worked just fine... I'm such a failure, this is what you get after you are in VB6 for 15 years and didn't touched it for the past 1-2 years!
    Last edited by beic; Oct 7th, 2022 at 02:31 PM. Reason: typo

  4. #4
    New Member
    Join Date
    Oct 2022
    Location
    Brazil
    Posts
    3

    Re: [RESOLVED] Shell CMD Text output format

    i'm glad it worked! Just try to not be so harsh with yourself!

    have a nice day

Tags for this Thread

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