Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Help: Checking for an internet page
 

Help: Checking for an internet page

I need a code so that if a page (http://www.herbertsworld.com/news/download.html) exist's, then when the application is started, it opens a new aplication named "Download.vb" in the Forms list.

Can someone do that?
Bailey Herbert  Sunday, March 08, 2009 10:21 PM
Download.vb is not an application name it could be the name ofthe code page of a form in your application though . What are you trying to do ?
Coding for fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
bdbodger  Sunday, March 08, 2009 10:41 PM
I need something so it opens Down.vb in my application when that page exists.
Bailey Herbert  Sunday, March 08, 2009 11:17 PM
Let us know what is download.vb here and how you open it in your scenario.

Also have a look at the following code snippet.

ImportsSystem.Net
ImportsSystem.IO
PublicClassForm1
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimmyClientAsWebClient=NewWebClient()
DimresponseAsStream
Try
response=myClient.OpenRead("http://www.contoso.com/index.htm")
Process.Start("notepad.exe")''modifyittoyourprocess
CatchwexAsWebException
'Thestreamdataisusedhere.
Console.WriteLine("TheURIformedbycombiningBaseAddress,addressisinvalid")
Console.WriteLine(wex.Message)
CatchexAsException
Console.WriteLine(ex.Message)
Finally
response.Close()
EndTry
EndSub
EndClass


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Riquel_Dong  Wednesday, March 11, 2009 4:47 AM
We are changing the issue type to “General Discussion�because you have not followed up. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions. Thank you!


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Monday, March 16, 2009 12:40 PM
So how would I make the application, "sload.vb" .Show() if the page exists?
Bailey Herbert  Wednesday, April 22, 2009 10:55 PM
Do you need to show form when web page exists?

Imports System.Net
Imports System.IO

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myClient As WebClient = New WebClient()
Dim response As Stream
Try
response = myClient.OpenRead("http://www.contoso.com/index.htm")
'Process.Start("notepad.exe") '' modify it to your process
Dim f As New Form
f.Show()
Catch wex As WebException
' The stream data is used here.
Console.WriteLine("The URI formed by combining BaseAddress, address is invalid")
Console.WriteLine(wex.Message)
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
response.Close()
End Try
End Sub
End Class

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Friday, April 24, 2009 9:02 AM
Now there are errors;

Error1Name 'Form2' is not declared.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb713HerbertsWorld2
Error2Syntax error.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb169HerbertsWorld2
Error3Syntax error.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb179HerbertsWorld2
Error4Type 'WebClient' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb1925HerbertsWorld2
Error5Type 'Stream' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb2025HerbertsWorld2
Error6Type 'WebException' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb2622HerbertsWorld2
Bailey Herbert  Tuesday, April 28, 2009 2:28 AM
Now there are errors;

Error1Name 'Form2' is not declared.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb713HerbertsWorld2
Error2Syntax error.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb169HerbertsWorld2
Error3Syntax error.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb179HerbertsWorld2
Error4Type 'WebClient' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb1925HerbertsWorld2
Error5Type 'Stream' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb2025HerbertsWorld2
Error6Type 'WebException' is not defined.C:\Users\Bailey\Documents\Visual Studio 2008\Projects\HerbertsWorld2\HerbertsWorld2\Form1.vb2622HerbertsWorld2
Bailey Herbert  Tuesday, April 28, 2009 2:29 AM
Yes, I do.
Bailey Herbert  Tuesday, April 28, 2009 2:30 AM
This shouldn't be too hard. Add a WebBrowser to your form, then add the following code:
  Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.DocumentTitle = titleofyourpage Then
            download.activate()
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://www.herbertsworld.com/news/download.html")
    End Sub
set the title of the "download.html" page to something unique. The second line of the code above will check to see if the title of the document is the title you specify. If the page exists, it will return true and then activate the download form
Hope this helps!
Thomas Shields  Wednesday, October 14, 2009 3:23 PM

You can use google to search for other answers

Custom Search

More Threads

• Quick question about varables
• How do I create an automation add-in for Excel in Visual Basic 2008 Express edition?
• crash: clr20r3 system.invalidoperationexception
• About editing input
• how to locate and install RSS.GIF file for visual basic express edition?
• why dont dims declared in an if statement get reconised?
• VBE Crashing..... often
• Slowness problem with Large Images
• Web-Browser Favorites
• Include a None option in a databound DropDownList