Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. modifying and displaying text from text file depending on content

modifying and displaying text from text file depending on content

Scheduled Pinned Locked Moved Visual Basic
tutoriallinuxquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    todda2008
    wrote on last edited by
    #1

    hi, sorry if this sounds a stupid question but im a beginer so bare with me this is my first non guide based project. im writing a program that creates a batch file from user entered data. it then runs and saves the batch file text + result as a text file. it then displays the text file in a textbox. this was fine but im trying to develop it further so i now need it to be more simple for the user with more features. the user can now choose how many times (1-10) the batchfile requests the data. this works well but the data returned is a complicated unformatted mess. i would like if possible for the program to read the final text file and return simple formatted results. eg: instead of "exact returned result for 5x run.. Pinging 192.168.1.1 with 32 bytes of data:Reply from 192.168.1.1: bytes=32 time=24ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Ping statistics for 192.168.1.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 3ms, Maximum = 24ms, Average = 7ms i would prefer just ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms and to say it failed for eg: "ping to 192.168.1.1 failed" i know theres more possible results but i'll sort that out later. i havnt a clue how to do this ive looked high and low but nothing works how i want as the data is completely different everytime. heres the process code so you can see where im at.. the reason its doubled up is it can ping to IP and name, i just found it easyier that way Private Sub Button1_Click() Handles Button1.Click Dim pingamount As Integer pingamount = NumericUpDown1.Value If RadioButton1.Checked = True Then If TextBox1.Text.Length = 0 Or TextBox2.Text.Length = 0 Or TextBox3.Text.Length = 0 Or TextBox4.Text.Length = 0 Then MsgBox("please enter a valid IP address") Else : TextBox5.Text = "" If Form3.TextBox1.TextLength = True Then Form3.Close() Dim fs As New FileStream("C:\ping.bat", FileMode.Create, FileAccess.Write) Dim s As New StreamWriter(fs) s.WriteLine("ping.exe -n " & pingamount & " " & TextBox1.Text & "." & TextBox2.Text & "." & TextBox3.Text & "." & TextBox4.Text & ">C:\ping.txt") s.Close() Shell("C:\ping.

    D 1 Reply Last reply
    0
    • T todda2008

      hi, sorry if this sounds a stupid question but im a beginer so bare with me this is my first non guide based project. im writing a program that creates a batch file from user entered data. it then runs and saves the batch file text + result as a text file. it then displays the text file in a textbox. this was fine but im trying to develop it further so i now need it to be more simple for the user with more features. the user can now choose how many times (1-10) the batchfile requests the data. this works well but the data returned is a complicated unformatted mess. i would like if possible for the program to read the final text file and return simple formatted results. eg: instead of "exact returned result for 5x run.. Pinging 192.168.1.1 with 32 bytes of data:Reply from 192.168.1.1: bytes=32 time=24ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Reply from 192.168.1.1: bytes=32 time=3ms TTL=64Ping statistics for 192.168.1.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 3ms, Maximum = 24ms, Average = 7ms i would prefer just ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms ping to 192.168.1.1 sucessful 3ms and to say it failed for eg: "ping to 192.168.1.1 failed" i know theres more possible results but i'll sort that out later. i havnt a clue how to do this ive looked high and low but nothing works how i want as the data is completely different everytime. heres the process code so you can see where im at.. the reason its doubled up is it can ping to IP and name, i just found it easyier that way Private Sub Button1_Click() Handles Button1.Click Dim pingamount As Integer pingamount = NumericUpDown1.Value If RadioButton1.Checked = True Then If TextBox1.Text.Length = 0 Or TextBox2.Text.Length = 0 Or TextBox3.Text.Length = 0 Or TextBox4.Text.Length = 0 Then MsgBox("please enter a valid IP address") Else : TextBox5.Text = "" If Form3.TextBox1.TextLength = True Then Form3.Close() Dim fs As New FileStream("C:\ping.bat", FileMode.Create, FileAccess.Write) Dim s As New StreamWriter(fs) s.WriteLine("ping.exe -n " & pingamount & " " & TextBox1.Text & "." & TextBox2.Text & "." & TextBox3.Text & "." & TextBox4.Text & ">C:\ping.txt") s.Close() Shell("C:\ping.

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      Do you need to use an external batch file? Can you not use the network classes from the framework directly?

      Dave Who am I?: http://www.bebo.com/daveauld/

      T 1 Reply Last reply
      0
      • D DaveAuld

        Do you need to use an external batch file? Can you not use the network classes from the framework directly?

        Dave Who am I?: http://www.bebo.com/daveauld/

        T Offline
        T Offline
        todda2008
        wrote on last edited by
        #3

        sadly im kinda new to this so its the only way i new i could try another way. could you go into more detail

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups