locked
how can i block this? RRS feed

  • Question

  • ive made a webrowser, with a parental controls panel, how can i block sites like youtube.com when they have that box checked
    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Sunday, October 4, 2009 12:30 PM

Answers

  •  Try similar thread Block a website by Program
    The code from the above link was C# but i converted it to VB, you can still visit the link to read the replies.

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim path As String = "C:\Windows\System32\drivers\etc\hosts"
            Dim sw As StreamWriter = New StreamWriter(path, true)
            Dim sitetoblock As String = ""& vbLf&" 127.0.0.1 google.com"
            sw.Write(sitetoblock)
            sw.Close
            MessageBox.Show("Site Blocked")
        End Sub
    
    kaymaf

    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    • Marked as answer by Darkhalodude Sunday, October 4, 2009 1:22 PM
    Sunday, October 4, 2009 1:12 PM

All replies

  •  Try similar thread Block a website by Program
    The code from the above link was C# but i converted it to VB, you can still visit the link to read the replies.

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim path As String = "C:\Windows\System32\drivers\etc\hosts"
            Dim sw As StreamWriter = New StreamWriter(path, true)
            Dim sitetoblock As String = ""& vbLf&" 127.0.0.1 google.com"
            sw.Write(sitetoblock)
            sw.Close
            MessageBox.Show("Site Blocked")
        End Sub
    
    kaymaf

    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    • Marked as answer by Darkhalodude Sunday, October 4, 2009 1:22 PM
    Sunday, October 4, 2009 1:12 PM
  • thanks, also how can i get it to block sites with specific words on it like www.youtube.com  
    detects it have the word tube on it andblocks the website
    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Sunday, October 4, 2009 1:22 PM
  • also with the code you gave me before there are 3 errors,

    streamwriter is not declared
    site to block is not declared
    End of statement exspected

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate(TextBox1.Text)
            ToolStripStatusLabel3.Text = "Loading"
            Dim path As String = "C:\Windows\System32\drivers\etc\hosts"
            Dim sw As StreamWriter = New StreamWriter(path, True)
            Dim sitetoblock As String = ""& vbLf&" 127.0.0.1 google.com"
            sw.Write(sitetoblock)
            sw.Close()
            MessageBox.Show("Site Blocked")
        End Sub

    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Sunday, October 4, 2009 2:01 PM
  • Error1 :  Imports System.IO
    Error2 :  sitetoblock is declared as string
    Dim sitetoblock As String = vbNewLine & " 127.0.0.1 " & "google.com" 'change google.com to the site you want to block

    if textbox1.text  is the site you want to block, then use
    Dim sitetoblock As String = vbNewLine & " 127.0.0.1 " &  TextBox1.Text 'change google.com to the site you 

     And the last error should be resolved by correction of error 2


    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Sunday, October 4, 2009 2:53 PM
  • no errors, but what type do i put it into progress changes????
    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Sunday, October 4, 2009 3:18 PM