Results 1 to 12 of 12

Thread: (Resolved) Help with Browser from Button Code...

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Resolved (Resolved) Help with Browser from Button Code...

    Ok, I have noticed that this code:

    VB Code:
    1. 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
    2.  
    3. Private Const SW_SHOWNORMAL = 1
    4.  
    5. Private Sub Command1_Click()
    6. ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
    7. End Sub
    8.  
    9. End Sub

    Returns this error statement when I go to compile it:

    "Only comments may appear after End Sub, End function, or End Property"

    and then it highlights this part:

    VB Code:
    1. 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

    Why am I receiving this message? What did I do wrong? Please help - Thanks
    Last edited by The Dude45; Dec 24th, 2004 at 11:48 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Help with Browser from Button Code...

    You have 2 (two) "End Sub"s so remove one:
    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" _
    2.     Alias "ShellExecuteA" _
    3.     (ByVal hwnd As Long, ByVal lpOperation As String, _
    4.      ByVal lpFile As String, ByVal lpParameters As String, _
    5.      ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Const SW_SHOWNORMAL = 1
    8.  
    9. Private Sub Command1_Click()
    10.     ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
    11. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Re: Help with Browser from Button Code...

    Ok, I removed the extra End Sub and I still receive the error message - ugh everyone else seems to be able to get it to work

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Help with Browser from Button Code...

    Open your code window and select Full Module View (little button at the left bottom corner) and check what you have there - you should only have one procedure header and one footer:

    Private Sub Command1_Click()

    End Sub

    If you see End Sub following by another End Sub (or some other garbage) then simply get rid of that ...

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Re: Help with Browser from Button Code...

    Ok I will post what is above and below the code, because I still have the problem:

    VB Code:
    1. Private Sub About_Click()
    2. AboutthisProduct.Show
    3. End Sub
    4.  
    5. Private Sub Continue_Click()
    6. ChooseMode.Show
    7. Opening.Hide
    8. End Sub
    9.  
    10. Private Sub Update_Click()
    11. Private Declare Function ShellExecute Lib "shell32.dll" _
    12.     Alias "ShellExecuteA" _
    13.     (ByVal hwnd As Long, ByVal lpOperation As String, _
    14.      ByVal lpFile As String, ByVal lpParameters As String, _
    15.      ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    16.  
    17. Private Const SW_SHOWNORMAL = 1
    18.  
    19. Private Sub Command1_Click()
    20.     ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
    21. End Sub

    That's everything that is in the currently selected frame within the form. I don't know if it being inside a frame has anything to do with it, but there you have it. Thanks!

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Help with Browser from Button Code...

    Get rid of this line:

    Private Sub Update_Click()

    You probably had this button at some point or perhaps still do but it's useless I guess.

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Re: Help with Browser from Button Code...

    Man I don't wanna seem like a pain, but deleting that line connects the Private Sub Contine_Click section with the "Update" browser button. The error continues to appear. Should I remove the frame or something?

  8. #8
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Help with Browser from Button Code...

    The declaration statements for the API and the constant must appear in the "general declarations" section of the form (i.e., prior to any Sub or Function). Rearrange your code as follows:
    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" _
    2.     Alias "ShellExecuteA" _
    3.     (ByVal hwnd As Long, ByVal lpOperation As String, _
    4.      ByVal lpFile As String, ByVal lpParameters As String, _
    5.      ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Const SW_SHOWNORMAL = 1
    8.  
    9. Private Sub About_Click()
    10.      AboutthisProduct.Show
    11. End Sub
    12.  
    13. Private Sub Continue_Click()
    14.     ChooseMode.Show
    15.     Opening.Hide
    16. End Sub
    17.  
    18. Private Sub Command1_Click()
    19.     ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
    20. End Sub
    "It's cold gin time again ..."

    Check out my website here.

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Smile Re: Help with Browser from Button Code...

    Bruce man you are the best! It works flawlessly! Thank you sooooo much - again, YOU ARE THE MAN!

  10. #10
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Help with Browser from Button Code...

    Glad to help. Merry Christmas!
    BTW - I see that you are new to the forum. The moderators have instituted a new convention to indicate that the issue has been resolved. What you do is edit your original post to show the green checkmark icon.
    "It's cold gin time again ..."

    Check out my website here.

  11. #11

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Thumbs up Re: Help with Browser from Button Code...

    Merry Christmas to you too! Thanks for the tip ====>Will do

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: (Resolved) Help with Browser from Button Code...

    sub Update_Click

    didn't have an End Sub, anyways.

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