Display results of a command in a text box

Author Message
cdiaz1116

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 3/4/2010
  • Status: offline
Display results of a command in a text box Friday, May 21, 2010 2:45 AM (permalink)
0
I am writing a set of tools and have the need to generate results and show them in the same form. For example. I have a Text box where I would type a host name. When I click ok the script will ping the host name. I want the results of the ping to display on the same form in a text box or Webbrowser control. I have been tinkering with a bunch of ideas but nothing seems to work. Any help would be appricieted.
 
#1
    ebgreen

    • Total Posts : 8219
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Display results of a command in a text box Friday, May 21, 2010 3:05 AM (permalink)
    0
    We'll need to see code to give concrete help but this is certainly doable.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      cdiaz1116

      • Total Posts : 5
      • Scores: 0
      • Reward points : 0
      • Joined: 3/4/2010
      • Status: offline
      Re:Display results of a command in a text box Friday, May 21, 2010 3:28 AM (permalink)
      0
      I tried having the results written to an HMTL file and then have a webbrowser control read the file.

      Dim objFSO, objFile, DataArea
      Shell(Command() &
      "ping.exe " & HostName.Text)
      objFSO = CreateObject(
      "Scripting.FileSystemObject")
      objFSO.CreateTextFile(
      "test.htm")
      objFile = objFSO.OpenTextFile(
      "test.htm", 2)
      objFile.WriteLine(DataArea.InnerHTML)
      objFile.Close()

      I would rather have it go directly to a text box though.
       
      #3
        ebgreen

        • Total Posts : 8219
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:Display results of a command in a text box Friday, May 21, 2010 3:37 AM (permalink)
        0
        I would suggest searching the forum for HTA. That is what I think you want.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          cdiaz1116

          • Total Posts : 5
          • Scores: 0
          • Reward points : 0
          • Joined: 3/4/2010
          • Status: offline
          Re:Display results of a command in a text box Friday, May 21, 2010 3:50 AM (permalink)
          0
          No Actually Im going from a working HTA and turning it into a VB project. Maybe thats where im going a little crazy.
           
          #5
            ebgreen

            • Total Posts : 8219
            • Scores: 98
            • Reward points : 0
            • Joined: 7/12/2005
            • Status: offline
            Re:Display results of a command in a text box Friday, May 21, 2010 5:20 AM (permalink)
            0
            Aaah...so you are doing this in VB? Just to be clear, VB is not VBScript(VBS) is not VB for Applications is not VB .Net.

            So which language are you actually using?
            "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
            Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
            http://www.visualbasicscript.com/m_47117/tm.htm
             
            #6
              cdiaz1116

              • Total Posts : 5
              • Scores: 0
              • Reward points : 0
              • Joined: 3/4/2010
              • Status: offline
              Re:Display results of a command in a text box Friday, May 21, 2010 7:43 AM (permalink)
              0
              VB. 

              I was looking for a way to directly pipe the result into a text box and bypass the creating and reading of a text file. Creating a text file works. See below. Although I dont know how to create a wait between the ping and the read of the file.
               
              Dim strOutFile
              strOutFile =
              "c:\deploy\temp.txt"
              Shell("cmd.exe /c ping.exe " & HostName.Text & " > " & StrOutFile)
               
              Dim xFile As String = "c:\deploy\temp.txt"
              Dim TextLine As String
              If System.IO.File.Exists(xFile) Then
              Dim Reader As System.IO.StreamReader = New System.IO.StreamReader(xFile)
              Do While Reader.Peek() <> -1
              TextLine = Reader.ReadToEnd() & vbNewLine
              TextBox1.Text = TextLine
              Loop
              Reader.Close()
              End If
              End Sub
               
              #7
                ebgreen

                • Total Posts : 8219
                • Scores: 98
                • Reward points : 0
                • Joined: 7/12/2005
                • Status: offline
                Re:Display results of a command in a text box Friday, May 21, 2010 7:48 AM (permalink)
                0
                I would not use ping.exe. I would use a call to the wsock32.dll.
                "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
                Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
                http://www.visualbasicscript.com/m_47117/tm.htm
                 
                #8
                  megna73

                  • Total Posts : 1
                  • Scores: 0
                  • Reward points : 0
                  • Joined: 7/26/2010
                  • Status: offline
                  Re:Display results of a command in a text box Monday, July 26, 2010 3:06 PM (permalink)
                  0
                    Private Sub UsernameTextBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles UsernameTextBox.Leave
                    'Make Connection to database
                    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Atlanet\loantracking\CTS_be.mdb")
                    'Query information for Branch Number
                    Dim BranchNumber As OleDbCommand = New OleDbCommand("SELECT Branch_Number From MSysUserList WHERE Username like '" & UsernameTextBox.Text & "'")
                    BranchNo.Text = BranchNumber
                    'Query information for User Group
                    Dim UserGroup As OleDbCommand = New OleDbCommand("SELECT UserGroup From MSysUserList WHERE Username like '" & UsernameTextBox.Text & "'")
                    UserGroupTextBox.Text = UserGroup
                    End Sub
                  Web Development Services

                   
                  #9
                    ginolard

                    • Total Posts : 1347
                    • Scores: 23
                    • Reward points : 0
                    • Joined: 8/11/2005
                    • Status: offline
                    Re:Display results of a command in a text box Sunday, August 15, 2010 7:09 PM (permalink)
                    0
                    I wouldn't use either of those.  I'd use the Ping method from System.Net.NetworkInformation

                    http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

                    Author of ManagePC - http://managepc.net

                     
                    #10

                      Online Bookmarks Sharing: Share/Bookmark

                      Jump to:

                      Current active users

                      There are 0 members and 1 guests.

                      Icon Legend and Permission

                      • New Messages
                      • No New Messages
                      • Hot Topic w/ New Messages
                      • Hot Topic w/o New Messages
                      • Locked w/ New Messages
                      • Locked w/o New Messages
                      • Read Message
                      • Post New Thread
                      • Reply to message
                      • Post New Poll
                      • Submit Vote
                      • Post reward post
                      • Delete my own posts
                      • Delete my own threads
                      • Rate post

                      2000-2012 ASPPlayground.NET Forum Version 3.9