/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
link i VBA
Fra : Nørholm


Dato : 19-11-04 12:23

et begynderspørgsmål:

Jeg vil gerne kunne lave en label i en form, der linker til/åbner en
internetside i et nyt vindue.
Hvordan gør mandet i Visual Basic 6.0?

Nørholm



 
 
Søren (19-11-2004)
Kommentar
Fra : Søren


Dato : 19-11-04 16:33

"Nørholm" <per.n.rasmussen@(fjern)stofanet.dk> wrote in message
news:419dd51e$0$17597$ba624c82@nntp06.dk.telia.net...
> et begynderspørgsmål:
>
> Jeg vil gerne kunne lave en label i en form, der linker til/åbner en
> internetside i et nyt vindue.
> Hvordan gør mandet i Visual Basic 6.0?
>

Indsæt nedenstående i et modul og kald proceduren med følgende kommando:

Private Sub Label1_Click()
Call Shell("http://windows.oreilly.com/news/vb_tips_1098.html")
End Sub





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

'#############################################################
'# This code was written by Emmett Dixson (c)1999. You may alter
'# this code, trade, steal, borrow, lend or give away this code.
'# However, this code has been regisered with the Library of
'# Congress as a literary acheivement and as such excludes it
'# from being known or proclaimed as "PUBLIC DOMAIN".
'#---------------You may NOT remove this header---------------
'#------------------You may NOT SELL this work----------------
'#----YES! You MAY use this work for commercial purposes------
'#---This code MAY NOT be sold or redistributed for profit----
'#-------- I wish you every success in your projects ---------
'#------------------------ Visit me at -----------------------
'#------------------http://developer.ecorp.net ---------------
'#-----------------FREE Visual Basic Source Code -------------
'##############################################################

'For best results paste everything into a NEW MODULE and be sure
'you SAVE the module to your project.

'Works for Win3.x, Win95,Win98,WinNT and EVEN Win2000(don't ask!)

'Don't change anything...just paste everything into ONE
'MODULE that you can add to a project.

Function Shell(Program As String, Optional ShowCmd As Long = _
vbNormalNoFocus, Optional ByVal WorkDir As Variant) As Long

Dim FirstSpace As Integer, Slash As Integer

If Left(Program, 1) = """" Then
FirstSpace = InStr(2, Program, """")


If FirstSpace <> 0 Then
Program = Mid(Program, 2, FirstSpace - 2) & _
Mid(Program, FirstSpace + 1)
FirstSpace = FirstSpace - 1
End If

Else
FirstSpace = InStr(Program, " ")
End If

If FirstSpace = 0 Then FirstSpace = Len(Program) + 1

If IsMissing(WorkDir) Then
For Slash = FirstSpace - 1 To 1 Step -1
If Mid(Program, Slash, 1) = "\" Then Exit For
Next
If Slash = 0 Then
WorkDir = CurDir
ElseIf Slash = 1 Or Mid(Program, Slash - 1, 1) = ":" Then
WorkDir = Left(Program, Slash)
Else
WorkDir = Left(Program, Slash - 1)
End If
End If

Shell = ShellExecute(0, vbNullString, _
Left(Program, FirstSpace - 1), LTrim(Mid(Program, _
FirstSpace)), WorkDir, ShowCmd)
If Shell < 32 Then VBA.Shell Program, ShowCmd 'To raise Error
End Function



Nørholm (22-11-2004)
Kommentar
Fra : Nørholm


Dato : 22-11-04 09:19

Tak for det hurtige svar.
Jeg har indsat nedenstående i et modul og her efter indsat det samme i en
label i en Form. Det virker ikke. Jeg får meldingen: File not found. Hvor er
det lige jeg gør noget forkert her?


VH
Per
"Søren" <ingenSpamTilMig@invalid> skrev i en meddelelse
news:419e1219$0$308$edfadb0f@dread11.news.tele.dk...
> "Nørholm" <per.n.rasmussen@(fjern)stofanet.dk> wrote in message
> news:419dd51e$0$17597$ba624c82@nntp06.dk.telia.net...
>> et begynderspørgsmål:
>>
>> Jeg vil gerne kunne lave en label i en form, der linker til/åbner en
>> internetside i et nyt vindue.
>> Hvordan gør mandet i Visual Basic 6.0?
>>
>
> Indsæt nedenstående i et modul og kald proceduren med følgende kommando:
>
> Private Sub Label1_Click()
> Call Shell("http://windows.oreilly.com/news/vb_tips_1098.html")
> End Sub
>
>
>
>
>
> 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
>
> '#############################################################
> '# This code was written by Emmett Dixson (c)1999. You may alter
> '# this code, trade, steal, borrow, lend or give away this code.
> '# However, this code has been regisered with the Library of
> '# Congress as a literary acheivement and as such excludes it
> '# from being known or proclaimed as "PUBLIC DOMAIN".
> '#---------------You may NOT remove this header---------------
> '#------------------You may NOT SELL this work----------------
> '#----YES! You MAY use this work for commercial purposes------
> '#---This code MAY NOT be sold or redistributed for profit----
> '#-------- I wish you every success in your projects ---------
> '#------------------------ Visit me at -----------------------
> '#------------------http://developer.ecorp.net ---------------
> '#-----------------FREE Visual Basic Source Code -------------
> '##############################################################
>
> 'For best results paste everything into a NEW MODULE and be sure
> 'you SAVE the module to your project.
>
> 'Works for Win3.x, Win95,Win98,WinNT and EVEN Win2000(don't ask!)
>
> 'Don't change anything...just paste everything into ONE
> 'MODULE that you can add to a project.
>
> Function Shell(Program As String, Optional ShowCmd As Long = _
> vbNormalNoFocus, Optional ByVal WorkDir As Variant) As Long
>
> Dim FirstSpace As Integer, Slash As Integer
>
> If Left(Program, 1) = """" Then
> FirstSpace = InStr(2, Program, """")
>
>
> If FirstSpace <> 0 Then
> Program = Mid(Program, 2, FirstSpace - 2) & _
> Mid(Program, FirstSpace + 1)
> FirstSpace = FirstSpace - 1
> End If
>
> Else
> FirstSpace = InStr(Program, " ")
> End If
>
> If FirstSpace = 0 Then FirstSpace = Len(Program) + 1
>
> If IsMissing(WorkDir) Then
> For Slash = FirstSpace - 1 To 1 Step -1
> If Mid(Program, Slash, 1) = "\" Then Exit For
> Next
> If Slash = 0 Then
> WorkDir = CurDir
> ElseIf Slash = 1 Or Mid(Program, Slash - 1, 1) = ":" Then
> WorkDir = Left(Program, Slash)
> Else
> WorkDir = Left(Program, Slash - 1)
> End If
> End If
>
> Shell = ShellExecute(0, vbNullString, _
> Left(Program, FirstSpace - 1), LTrim(Mid(Program, _
> FirstSpace)), WorkDir, ShowCmd)
> If Shell < 32 Then VBA.Shell Program, ShowCmd 'To raise Error
> End Function
>
>



Søren (22-11-2004)
Kommentar
Fra : Søren


Dato : 22-11-04 13:21

"Nørholm" <per.n.rasmussen@(fjern)stofanet.dk> wrote in message
news:41a19e73$0$17583$ba624c82@nntp06.dk.telia.net...
> Tak for det hurtige svar.
> Jeg har indsat nedenstående i et modul og her efter indsat det samme i en
> label i en Form. Det virker ikke. Jeg får meldingen: File not found. Hvor
> er det lige jeg gør noget forkert her?
>
>
Proceduren er egentlig beregnet til at åbne et program, altså en exe-fil.
Prøv f med "notepad.exe".

Den virker kun med datafiler, der er knyttet til et program. Det kan så være
txt eller html eller noget andet, så åbner proceduren automatisk det
tilknyttede program. Desuden skal URL'en selvfølgelig være gyldig.

Søren



Steen Alcor (26-11-2004)
Kommentar
Fra : Steen Alcor


Dato : 26-11-04 15:37

Prøv med følgende funktion

Public Sub ShowInternet()
Dim iret
iret = ShellExecute([Navnet få den form du kalder fra].hwnd, _
vbNullString, "http://WWW.MICROSOFT.COM", _
vbNullString, "C:\", 1)
End Sub


"Nørholm" <per.n.rasmussen@(fjern)stofanet.dk> skrev i en meddelelse
news:419dd51e$0$17597$ba624c82@nntp06.dk.telia.net...
> et begynderspørgsmål:
>
> Jeg vil gerne kunne lave en label i en form, der linker til/åbner en
> internetside i et nyt vindue.
> Hvordan gør mandet i Visual Basic 6.0?
>
> Nørholm
>
>



Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408914
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste