Denne kode åbner en browser med den URL der står i en Caption (Label1) når man kilkker på den. Jeg går ud fra at du selv kan rette den til.
Private Const SW_SHOW = 5 \' Displays Window in its current size and position Private Const SW_SHOWNORMAL = 1 \' Restores Window if Minimized or Maximized
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 Declare Function FindExecutable Lib \"shell32.dll\" Alias _ \"FindExecutableA\" (ByVal lpFile As String, ByVal lpDirectory As _ String, ByVal lpResult As String) As Long
Dim CurrentBrowser As String
Private Sub Label1_Click() Dim RetVal As Long
If CurrentBrowser = \"\" Then CurrentBrowser = FindBrowser RetVal = ShellExecute(Me.hwnd, \"open\", CurrentBrowser, Label1.Caption, Dummy, SW_SHOWNORMAL) If RetVal <= 32 Then \' Error MsgBox \"Web Page not Opened\", vbExclamation, \"URL Failed\" End If End Sub
Private Function FindBrowser() As String Dim FileName As String, Dummy As String Dim BrowserExec As String * 255 Dim RetVal As Long Dim FileNumber As Integer
\' First, create a known, temporary HTML file BrowserExec = Space(255) FileName = \"C:\\temphtm.HTM\" FileNumber = FreeFile \' Get unused file number Open FileName For Output As #FileNumber \' Create temp HTML file Write #FileNumber, \"<HTML> <\\HTML>\" \' Output text Close #FileNumber \' Close file \' Then find the application associated with it RetVal = FindExecutable(FileName, Dummy, BrowserExec) BrowserExec = Trim(BrowserExec) \' If an application is found, launch it! If RetVal <= 32 Or IsEmpty(BrowserExec) Then \' Error MsgBox \"Could not find associated Browser\", vbExclamation, \"Browser Not Found\" Else FindBrowser = BrowserExec End If Kill FileName \' delete temp HTML file End Function
Public 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
Public Const SHOW_FULLSCREEN = 3
Private Sub Command1_Click() R = ShellExecute(Me.hwnd, \"Open\", Text1.Text, vbNullString, App.Path, SHOW_FULLSCREEN) End Sub
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.