چه طور می تونم با زدن روی یه command button با باز کردن اینترنت اکسپلورر به یه آدرس اینتر نتی برم ؟
Printable View
چه طور می تونم با زدن روی یه command button با باز کردن اینترنت اکسپلورر به یه آدرس اینتر نتی برم ؟
کد:
Shell "Explorer.exe http:\\www.google.com"
کد:
کد:
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
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Const SW_SHOWNORMAL = 1
Const CodeID = 26900
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Ok_Click()
GotoURL ("http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=50695&lngWId=1")
End Sub
Sub GotoURL(URL As String)
Dim Res As Long
Dim TFile As String, Browser As String, Dum As String
TFile = App.Path + "\test.htm"
Open TFile For Output As #1
Close
Browser = String(255, " ")
Res = FindExecutable(TFile, Dum, Browser)
Browser = Trim$(Browser)
If Len(Browser) = 0 Then
MsgBox "Cannot find browser"
Exit Sub
End If
Res = ShellExecute(Me.hwnd, "open", Browser, URL, Dum, SW_SHOWNORMAL)
If Res <= 32 Then
MsgBox "Cannot open web page"
Exit Sub
End If
End Sub