(Resolved) Help with Browser from Button Code...
Ok, I have noticed that this code:
VB 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
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
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:
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 :)
Re: Help with Browser from Button Code...
You have 2 (two) "End Sub"s so remove one:
VB 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
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
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 :mad:
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 ...
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:
Private Sub About_Click()
AboutthisProduct.Show
End Sub
Private Sub Continue_Click()
ChooseMode.Show
Opening.Hide
End Sub
Private Sub Update_Click()
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
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
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! :)
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.
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?
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:
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
Private Const SW_SHOWNORMAL = 1
Private Sub About_Click()
AboutthisProduct.Show
End Sub
Private Sub Continue_Click()
ChooseMode.Show
Opening.Hide
End Sub
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "http://www.microsoft.com/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
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! :) :wave: :)
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.
Re: Help with Browser from Button Code...
Merry Christmas to you too! Thanks for the tip ====>Will do :)
Re: (Resolved) Help with Browser from Button Code...
sub Update_Click
didn't have an End Sub, anyways.