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

try this

Dim txturl as string

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

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

there is an error on this part:

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

is says: object required.

Yes because it's a API call missing.

Try this...


---

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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Send an E-Mail to the KPD-Team
    ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
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...

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
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
    'example by Matthew Gates (Puff0rz@hotmail.com)
    DownloadFile "http://www.allapi.net", "c:\allapi.htm"
End Sub

there is an error on this part:


is says: object required.

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

:) 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

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.

Yes because it's a API call missing.

Try this...


---

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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Send an E-Mail to the KPD-Team
    ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
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...

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
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
    'example by Matthew Gates (Puff0rz@hotmail.com)
    DownloadFile "http://www.allapi.net", "c:\allapi.htm"
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.

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...

I will try your code and will give you the feedback as soon as I can.

cguan_77 has written the right code for this. Use his code in this way : -

Private Sub Command1_Click()
Dim txturl As String
txturl = "http://www.google.com"
Shell "C:\Program Files\Internet Explorer\IExplore.exe " & txturl, vbMaximizedFocus
End Sub

Your right (provided you use MSIE for all surfing)
My post would open the users preferred default browser instead.
That is the only difference.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.