Results 1 to 14 of 14

Thread: Problem with Streamreader and Notify Icon Tip

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Exclamation Problem with Streamreader and Notify Icon Tip

    im having problem with this code, what i want it to do it go on the site nd if it finds the word online it switches the text

    so say it directed to google and the word online is somewhere in the html code of the site, the app should then change label 5 to online
    BUT i get this error

    "Could not find file 'C:\Users\Owner\Desktop\AMi BETA\AMi BETA\bin\Debug\www.google.com'."
    -----------------------
    everything i want the notifyicon to do is working but i only want it to pop up once but every time the timer ticks it pops up

    Code:
     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ServerStatus.Tick
            Dim LB5 As String = Label5.Text
            Dim wc As New System.Net.WebClient()
            Dim sr As New IO.StreamReader(wc.OpenRead(LB5))
          Dim s As String = sr.ReadToEnd()
              sr.Close()
            If s.Contains("Online") Then
                Status.Text = "Online"
                Status.ForeColor = Color.LimeGreen
                If Me.Visible = False Then
                    'Tip Pops up
                    NotifyIcon1.BalloonTipText = Label1.Text & " is Online!"
                    NotifyIcon1.ShowBalloonTip(5000)
    
                End If
            Else
                Me.Status.Text = "Offline"
                Status.ForeColor = Color.Red
            End If
        End Sub
    Last edited by iace; Feb 26th, 2011 at 06:43 AM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    bump

  3. #3
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    You're doing it wrong...
    You need to download/open the URL, so you can use the method OpenRead with a string...

    Example adapted from MSDN.
    vb.net Code:
    1. Dim client As New WebClient()
    2. Dim pageData As [Byte]() = client.DownloadData(Label5.Text)
    3. Dim s As String = Encoding.ASCII.GetString(pageData)

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    sorry i have no clue what do do with that i put it in and i got the same error

  5. #5
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    That can't find www.google.com?!!?

    vb.net Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ServerStatus.Tick
    2.         Dim client As New WebClient()
    3.         Dim pageData As [Byte]() = client.DownloadData(Label5.Text)
    4.         Dim s As String = Encoding.ASCII.GetString(pageData)
    5.         If s.Contains("Online") Then
    6.             Status.Text = "Online"
    7.             Status.ForeColor = Color.LimeGreen
    8.             If Me.Visible = False Then
    9.                 'Tip Pops up
    10.                 NotifyIcon1.BalloonTipText = Label1.Text & " is Online!"
    11.                 NotifyIcon1.ShowBalloonTip(5000)
    12.  
    13.             End If
    14.         Else
    15.             Status.Text = "Offline"
    16.             Status.ForeColor = Color.Red
    17.         End If
    18.     End Sub

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    Quote Originally Posted by mickey_pt View Post
    That can't find www.google.com?!!?

    vb.net Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ServerStatus.Tick
    2.         Dim client As New WebClient()
    3.         Dim pageData As [Byte]() = client.DownloadData(Label5.Text)
    4.         Dim s As String = Encoding.ASCII.GetString(pageData)
    5.         If s.Contains("Online") Then
    6.             Status.Text = "Online"
    7.             Status.ForeColor = Color.LimeGreen
    8.             If Me.Visible = False Then
    9.                 'Tip Pops up
    10.                 NotifyIcon1.BalloonTipText = Label1.Text & " is Online!"
    11.                 NotifyIcon1.ShowBalloonTip(5000)
    12.  
    13.             End If
    14.         Else
    15.             Status.Text = "Offline"
    16.             Status.ForeColor = Color.Red
    17.         End If
    18.     End Sub
    i get a error

    the google thing was just a example
    Attached Images Attached Images  
    Last edited by iace; Feb 26th, 2011 at 05:20 PM.

  7. #7
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    You need to import the namespaces or to put the complete code...

    vb.net Code:
    1. Imports System.Net
    2. Imports System.Text

    or

    vb.net Code:
    1. Dim client As New System.Net.WebClient()
    2. Dim s As String = System.Text.Encoding.ASCII.GetString(pageData)

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    Quote Originally Posted by mickey_pt View Post
    You need to import the namespaces or to put the complete code...

    vb.net Code:
    1. Imports System.Net
    2. Imports System.Text

    or

    vb.net Code:
    1. Dim client As New System.Net.WebClient()
    2. Dim s As String = System.Text.Encoding.ASCII.GetString(pageData)
    same error
    Attached Images Attached Images  

  9. #9
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    Just put in the label http://www.google.com, don't forget the http://

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    Thankyouuu >.<
    do you know how to fix the notifyicon tip?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    bump, i just need to find out the problem with the notifyicon now

  12. #12
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    What's the problem?

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: Problem with Streamreader and Notify Icon Tip

    Code:
    If s.Contains("Online") Then
                Status.Text = "Online"
                Status.ForeColor = Color.LimeGreen
                If Me.Visible = False Then
                    'Tip Pops up
                    NotifyIcon1.BalloonTipText = Label1.Text & " is Online!"
                    NotifyIcon1.ShowBalloonTip(5000)
    
                End If
            Else
                Me.Status.Text = "Offline"
                Status.ForeColor = Color.Red
            End If
    thats the problem, when the program is in the taskbar it spams the notifyicon and i only what it to pop up once for evey time it changes from offline to online

  14. #14
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problem with Streamreader and Notify Icon Tip

    Use a var to save the last state, and then in the tick event, check if the current state it's like the last state, if it's equal don't do anything, if not, show the notify icon and set the last state equals to the current state...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

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