Target a web link, help me please.

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Target a web link, help me please.

 
0
  #1
Feb 28th, 2009
Hallo to all, I am making an application that will target a particular link in the internet as if some is clicking it. I have a button target. Can anyone help me? please

Regards,
Neil
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,120
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Target a web link, help me please.

 
0
  #2
Feb 28th, 2009
try this

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim txturl as string
  2.  
  3. txturl ="http://www.daniweb.com"
  4.  
  5. Shell "C:\Program Files\Internet Explorer\IExplore.exe " & txurl.Text, vbMaximizedFocus
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Target a web link, help me please.

 
0
  #3
Mar 3rd, 2009
there is an error on this part:
Shell "C:\Program Files\Internet Explorer\IExplore.exe " & txurl.Text,
is says: object required.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 36
Reputation: javmedia is an unknown quantity at this point 
Solved Threads: 5
javmedia javmedia is offline Offline
Light Poster

Re: Target a web link, help me please.

 
0
  #4
Mar 3rd, 2009
Yes because it's a API call missing.

Try this...


---
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  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. Const SW_SHOWNORMAL = 1
  3. Private Sub Form_Load()
  4. 'KPD-Team 1998
  5. 'URL: http://www.allapi.net/
  6. 'E-Mail: KPDTeam@Allapi.net
  7. 'Send an E-Mail to the KPD-Team
  8. ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
  9. End Sub

you can replace the mailto: part with any valid URL excluding http://
Kudos to the API-guide guys who are unfortunately closing down now.

This seems pretty cool too...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  3. Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
  4. Dim lngRetVal As Long
  5. lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
  6. If lngRetVal = 0 Then DownloadFile = True
  7. End Function
  8. Private Sub Form_Load()
  9. 'example by Matthew Gates (Puff0rz@hotmail.com)
  10. DownloadFile "http://www.allapi.net", "c:\allapi.htm"
  11. End Sub
Last edited by javmedia; Mar 3rd, 2009 at 1:21 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,120
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Target a web link, help me please.

 
0
  #5
Mar 3rd, 2009
Originally Posted by nagatron View Post
there is an error on this part:


is says: object required.
sorry missing "t", i put txurl.. should be txturl

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim txturl as string
  2.  
  3. txturl ="http://www.daniweb.com"
  4.  
  5. Shell "C:\Program Files\Internet Explorer\IExplore.exe " & txturl.Text, vbMaximizedFocus
Last edited by cguan_77; Mar 3rd, 2009 at 2:57 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 36
Reputation: javmedia is an unknown quantity at this point 
Solved Threads: 5
javmedia javmedia is offline Offline
Light Poster

Re: Target a web link, help me please.

 
0
  #6
Mar 3rd, 2009
If I counted every time I missplaced a semi colon and had one penny for all the missing leading letters, we could buy Microsoft by now *lol*
You're in good company
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Target a web link, help me please.

 
0
  #7
Mar 3rd, 2009
Originally Posted by cguan_77 View Post
sorry missing "t", i put txurl.. should be txturl

Dim txturl as string

txturl ="http://www.daniweb.com"

Shell "C:\Program Files\Internet Explorer\IExplore.exe " & txturl.Text, vbMaximizedFocus

the error in this code is invalid quantifiers.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Target a web link, help me please.

 
0
  #8
Mar 3rd, 2009
Originally Posted by javmedia View Post
Yes because it's a API call missing.

Try this...


---
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  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. Const SW_SHOWNORMAL = 1
  3. Private Sub Form_Load()
  4. 'KPD-Team 1998
  5. 'URL: http://www.allapi.net/
  6. 'E-Mail: KPDTeam@Allapi.net
  7. 'Send an E-Mail to the KPD-Team
  8. ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
  9. End Sub

you can replace the mailto: part with any valid URL excluding http://
Kudos to the API-guide guys who are unfortunately closing down now.

This seems pretty cool too...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  3. Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
  4. Dim lngRetVal As Long
  5. lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
  6. If lngRetVal = 0 Then DownloadFile = True
  7. End Function
  8. Private Sub Form_Load()
  9. 'example by Matthew Gates (Puff0rz@hotmail.com)
  10. DownloadFile "http://www.allapi.net", "c:\allapi.htm"
  11. End Sub

I am having a hard time to understand the code. .can I have a simple example program using your code? I just want to know how it works so I can get the analysis. Thank you so much.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 36
Reputation: javmedia is an unknown quantity at this point 
Solved Threads: 5
javmedia javmedia is offline Offline
Light Poster

Re: Target a web link, help me please.

 
0
  #9
Mar 3rd, 2009
I'll break it down for you...

'inserts a definition of a Windows API function from the DLL file shell32.dll returning a LONG value
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

' A constant used by the function to specify Show the opened window as normal, neither minimized or maximized
Const SW_SHOWNORMAL = 1

' on loading the form, which this code is in, execute this function...
Private Sub Form_Load()
'Open the default browser and go to URL...
    ShellExecute Me.hwnd, vbNullString, "http://www.yourdomain.com", vbNullString, "C:\", SW_SHOWNORMAL
End Sub

Me.hwnd = the calling applications ID/reference to shell32.dll
vbNullString = NULL as "Not Specified" as a variable in the call to shell32.dll
C:\ = the default root drive / starting directory for the called application
SW_SHOWNORMAL = calling shell32.dll specifying the behaviour of the opened application window

You cannot get much simpler than this...
Last edited by javmedia; Mar 3rd, 2009 at 4:51 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: nagatron is an unknown quantity at this point 
Solved Threads: 0
nagatron nagatron is offline Offline
Junior Poster in Training

Re: Target a web link, help me please.

 
0
  #10
Mar 3rd, 2009
I will try your code and will give you the feedback as soon as I can.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC