View Single Post
Old Apr 22nd, 2008, 6:19 PM   #6
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 231
Rep Power: 1 Jabo is on a distinguished road
Re: Difference between test and production?

Well, I fixed the problem by moving the check for success into the IF statement. Now it only prints one instance of each error.

I still don't know why this caused the error.

vb Syntax (Toggle Plain Text)
  1. Do While sr.EndOfStream = False
  2. 'Read in a line from file
  3. linecheck = sr.ReadLine
  4.  
  5. 'Check that line read isn't empty string and that it contains 2 parts, otherwise discard
  6. If ((linecheck = "") Or (linecheck.Contains(",") = False)) Then
  7. Else
  8. 'If ok, split read line and put in entry
  9. entry = linecheck.Split(",")
  10. Dim Ping As Ping = New Ping
  11. Dim PingReply As PingReply
  12. success = 0
  13. For t As Integer = 0 To 3
  14. If entry(0) = "y" Then
  15. PingReply = Ping.Send(entry(1), 2000)
  16. 'Set current activity on toolstrip and cause repaint
  17. tssActivity.Text = "Current Task: Pinging " & entry(2) & ": " & entry(1)
  18. tssActivity.Invalidate()
  19. 'Set result parts 1 & 2 to current ping entry
  20. line(0) = entry(2) & ": "
  21. line(1) = entry(1)
  22. 'Set result part 3 (line(2)) to ping if success, error message if failed
  23. If PingReply.Status = IPStatus.Success Then
  24. line(2) = PingReply.RoundtripTime.ToString
  25. success += 1
  26. Else
  27. line(2) = PingReply.Status.ToString
  28. errtemp = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  29. End If
  30. End If
  31. Ping.Dispose()
  32. Next
  33. If success = 0 Then
  34. errstring += errtemp
  35. End If
  36. End If
  37.  
  38.  
  39. 'Set result string (line(3))
  40. line(3) = line(0) & Chr(13) & Chr(10) & line(1) & Chr(9) & Chr(9) & "Ping: " & line(2) & Chr(13) & Chr(10)
  41. rtbResult.Text += line(3)
  42. 'kill ping after used
  43. rtbResult.Invalidate()
  44. Me.Refresh()
  45. Loop
Jabo is offline   Reply With Quote