VisualBasic Snippets  

Eine URL im Standardbrowser öffnen:
 

Um eine URL im Standardbrowser zu öffnen kann man (warum auch immer) nicht mit dem Befehl SHELL arbeiten, man benötigt die API-Funktion ShellExecute.

Legen Sie das folgende Formular an:

Quelltext der Anwendung:


'API-Function deklarieren
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

'Konstante deklarieren
Private Const SW_SHOWNORMAL = 1

'------------------------------------------------------------
Private Sub btnSenden_Click()
Dim tsDummy

    tsDummy = tsSendAnMail(txtAdresse.Text, txtKopie.Text, txtBetreff.Text, txtText.Text)
    
End Sub

'------------------------------------------------------------
Private Sub btnURL_Click()
Dim tsDummy

    tsDummy = tsOpenURL(txtURL.Text)

End Sub

'------------------------------------------------------------
Function tsOpenURL(tsURL As String)

    tsOpenURL = ShellExecute(0&, vbNullString, tsURL, vbNullString, vbNullString, SW_SHOWNORMAL)

End Function

'------------------------------------------------------------
Function tsSendAnMail(tsAdresse As String, tsCopy As String, tsBetreff As String, stText As String)
Dim tsEmail As String

    tsEmail = "mailto:" & txtAdresse & "?CC=" & txtKopie & "&Subject=" & txtBetreff & "&Body=" & txtText
    
    tsSendAnMail = ShellExecute(0&, vbNullString, tsEmail, vbNullString, vbNullString, SW_SHOWNORMAL)

End Function

'------------------------------------------------------------
Private Sub btnClose_Click()

    End

End Sub
 


  Download VB6
Projekt-Quellcode
Download
Demo-Exe

© '2000 by T. Schindzielorz