Comment faire un lien entre vb et une page web ???

nashoy Messages postés 125 Date d'inscription dimanche 6 avril 2003 Statut Membre Dernière intervention 7 octobre 2006 - 25 mai 2003 à 15:38
BURAK77 Messages postés 6 Date d'inscription dimanche 29 juin 2008 Statut Membre Dernière intervention 12 juin 2012 - 9 oct. 2008 à 08:00
slt, jaimerai savoir comment faire pour que si je clique sur un bouton, que sa ouvre une ou plusieurs pages web... merci de répondre.a+
>:) nashoy 8-)

4 réponses

vjeux Messages postés 92 Date d'inscription lundi 14 avril 2003 Statut Membre Dernière intervention 5 décembre 2003
25 mai 2003 à 15:41
Mets ca dans un module :

Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" _
        (ByVal lpAppName As String, _
        ByVal lpCommandLine As String, _
        ByVal lpProcessAttributes As Long, _
        ByVal lpThreadAttributes As Long, _
        ByVal bInheritHandles As Long, _
        ByVal dwCreationFlags As Long, _
        ByVal lpEnvironment As Long, _
        ByVal lpCurrentDirectory As Long, _
        lpStartupInfo As STARTUPINFO, _
        lpProcessInformation As PROCESS_INFORMATION) As Long
     
Private Declare Function CloseHandle Lib "kernel32" _
        (ByVal hObject As Long) As Long

Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
        (ByVal lpFile As String, _
        ByVal lpDirectory As String, _
        ByVal sResult As String) As Long

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
        (ByVal nSize As Long, _
        ByVal lpBuffer As String) As Long

Private Const NORMAL_PRIORITY_CLASS As Long = &H20
Private Const STARTF_USESHOWWINDOW As Long = &H1
Private Const SW_SHOWNORMAL As Long = 1

Private Const MAX_PATH As Long = 260
Private Const ERROR_FILE_SUCCESS As Long = 32 'my constant

Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadID As Long
End Type

Public Function StartNewBrowser(sURL As String) As Boolean
    Dim success As Long
    Dim hProcess As Long
    Dim sBrowser As String
    Dim start As STARTUPINFO
    Dim proc As PROCESS_INFORMATION
    sBrowser = GetBrowserName(success)
    If success >= ERROR_FILE_SUCCESS Then
        With start
            .cb = Len(start)
            .dwFlags = STARTF_USESHOWWINDOW
            .wShowWindow = SW_SHOWNORMAL
        End With
        success = CreateProcess(sBrowser, " " & sURL, 0&, 0&, 0&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
        StartNewBrowser = proc.hProcess <> 0
        Call CloseHandle(proc.hProcess)
        Call CloseHandle(proc.hThread)
    End If
End Function

Private Function GetBrowserName(dwFlagReturned As Long) As String
    Dim hFile As Long
    Dim sResult As String
    Dim sTempFolder As String
    sTempFolder = GetTempDir()
    hFile = FreeFile
        Open sTempFolder & "Bidon.html" For Output As #hFile
        Close #hFile
    sResult = Space$(MAX_PATH)
    dwFlagReturned = FindExecutable("Bidon.html", sTempFolder, sResult)
    Kill sTempFolder & "Bidon.html"
    GetBrowserName = TrimNull(sResult)
End Function

Private Function TrimNull(Item As String)
    Dim pos As Integer
    pos = InStr(Item, Chr(0))
    If pos Then
        TrimNull = Left(Item, pos - 1)
    Else
        TrimNull = Item
    End If
End Function

Private Function GetTempDir() As String
    Dim tmp As String
    tmp = Space(MAX_PATH)
    Call GetTempPath(Len(tmp), tmp)
    GetTempDir = TrimNull(tmp)
End Function


Et ca dans ta form

Private Sub Command1_Click()
  StartNewBrowser ("http://vbfrance.com/")
End Sub
0
cs_kernel32 Messages postés 8 Date d'inscription samedi 23 novembre 2002 Statut Membre Dernière intervention 16 janvier 2006
16 mai 2005 à 17:01
oui... et pour les utilisateur de firefox ???

parce que cette methode ne marche pas...

merci
0
brayanjava Messages postés 1 Date d'inscription mardi 5 juin 2007 Statut Membre Dernière intervention 4 mai 2008
4 mai 2008 à 16:54
comment je peut interdit l'accées à une page web avec vb.net 2005 (code source ou les class que je peut utiliser svp) merci !!!!!
0
BURAK77 Messages postés 6 Date d'inscription dimanche 29 juin 2008 Statut Membre Dernière intervention 12 juin 2012
9 oct. 2008 à 08:00
Sa marche pas -_- j'ai bien fais le module
0
Rejoignez-nous