Results 1 to 3 of 3

Thread: Opening my webpage from my program

  1. #1
    Guest
    I was wondering if there was a better way to start your webpage than the code below:

    Shell "Explorer http://www.IgniteSoft.com/", vbHide

    The above works fine, but when I try a more complex URL (like my order form) it gives me an error:

    Shell "Explorer https://www.regnow.com/softsell/nph-...i?item=3679-1", vbHide


    I know using start.exe will work, but there is no start.exe in Windows 2000.

    Any ideas?

    -Jordan

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Use the ShellExecute API function.
    Code:
    Private Declare Function ShellExecute _
     Lib "shell32.dll" Alias "ShellExecuteA" ( _
     ByVal hwnd As Long, _
     ByVal lpOperation As String, _
     ByVal lpFile As String, _
     ByVal lpParameters As String, _
     ByVal lpDirectory As String, _
     ByVal nShowCmd As Long) As Long
    Now to make the call just do the following.
    Code:
    ShellExecute 0, "Open", "http://www.whatever.com", "", "", vbNormalFocus
    Good luck!

  3. #3
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67

    Create a web browser in your app!

    I found this information here on VB-World somewhere!
    Hope this Helps!


    Flint

    Creating a simple web browser

    Now you will learn how to create a simple browser with one line of code! Launch Visual Basic and select "Custom Controls" from the "Tools" menu. Check "Microsoft Internet Controls" and click OK. Two icons will appear on the toolbox (If you can't see the toolbox, go to the "View" menu and click "Toolbox").

    Now, click the world image on the toolbar and then draw out the control onto the form. You have now added the WebBrowser control to your project.

    Now you just need to direct the browser to a certain site. Select the form and click F7 to open up the code window. In the Form_Load event, type in the following code:

    Code:
    WebBrowser1.Navigate "http://visualbasic.about.com"
    Now, run the project by pressing F5 or the Run button on the ToolBar. With luck, the WebBrowser control will connect to the About.com server and download the Visual Basic home page (you may be prompted to dial into your service provider).

    You have just created a working WebBrowser with one line of code! The next part of this feature will show you how to add a drop-down list to allow the user to select a past address to visit, or type in a new address.

    Adding an Address Box

    One of the most essential features of your web browser is a box where you can type in the address of a web site to visit. Most modern browsers now feature a drop-down list of past web sites as well.

    First, add a combo box to the form as shown in Figure 2. This box will contain the list of past sites that you have visited.

    Now you can add the code to the Combo1.Click event that will allow the user to select a site from the drop down list to visit.

    Code:
    Private Sub Combo1_Click()
    WebBrowser1.Navigate (Combo1.Text)
    
    End Sub
    Remember that the user may also type in the address of a web site to visit, and then press the enter key to go to the site. In order to make the Combo box redirect the WebBrowser control to the site when the user clicks the enter key, use the KeyPress event to detect the KeyAscii code of 13, which is the ASCII code for the enter key.

    Code:
    Private Sub Combo1_KeyPress(KeyAscii As Integer)
    
    If KeyAscii = 13 Then
    Combo1_Click
    End If
    
    End Sub
    Finally, you have to add the code the actually adds items into the drop down list. When the WebBrowser control visits a site, it triggers the BeforeNavigate event. [B]You can place code in this event to add the site into the Combo box.

    Code:
    Private Sub WebBrowser1_BeforeNavigate(ByVal URL As String, _ 
    ByVal Flags As Long, ByVal TargetFrameName As String, _
    PostData As Variant, ByVal Headers As String, Cancel As _
    Boolean)
    
    Dim strURL As String
    strURL = URL
    Dim bFound As Boolean
    Dim i As Integer
    
    For i = 0 To Combo1.ListCount - 1
    If Combo1.List(i) = strURL Then
    bFound = True
    Exit For
    End If
    Next i
    
    If Not bFound Then
    Combo1.AddItem strURL
    End If
    
    Combo1.Text = strURL
    
    End Sub
    Adding Back and Forward Navigation Buttons

    Finally, your browser needs to offer a way for users to go back and forward between pages. Fortunately, the WebBrowser control offers two procedures that you can use:

    GoBack

    GoForward

    Add two command buttons to the form

    Code:
    'In the Command1 Click event, add the following code:
    
    On Error Resume Next
    WebBrowser1.GoBack
    
    'In the Command2 Click event, add the following code:
    
    On Error Resume Next
    WebBrowser1.GoForward
    Now run the program! You will now be able to use the application as a fully working web browser, and use the two command buttons to navigate between pages you have already seen.

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