![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
Button links to applications
I'm having a go at VB and i'm trying to make a small program that will have buttons that link to applications (fast, easy access). But i can't actually get the buttons to link to anything. How would i go about making the buttons link to a program on my computer?
|
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Dunno which version you're using, but assuming you're using < VB6, you can use the AppActivate function.
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
How do i do that? lol sorry.
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
I suggest reading a number of tutorials on Visual Basic, as you don't even know how to use a function.
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
Ok, i had a look up for functions etc on google. But the AppActivate function only activates a program that is already running(as i discovered when building), i am trying to start a process. I'll have a look for another function or i'll try to find a way to work around it. Thanks for the help
![]() |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Check out the Shell function.
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
After a bit more searching, i found this:
System.Diagnostics.Process.Start("Path") It works fine, i just need to link it to the buttons now. ![]() |
|
|
|
|
|
#8 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Ah... you're using Visual Basic .NET or Visual Basic 2005 (which uses the .NET framework, but they dropped the ".NET" name for the language), not Visual Basic. Please post in the correct forum next time.
|
|
|
|
|
|
#9 |
|
Programmer
|
AppActivate wouldn't work for what your doing. Shell could work but would be tricky. I reccomend the ShellExecute API. Place this in a module.
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 Sub Execute(ByVal FormHWND As Long, ByVal Path As String) ShellExecute FormHWND, "Open", Path, 0&, 0&, 1 End Sub Private Sub Command1_Click() Execute Me.hWND, "Notepad" End Sub Private Sub Command1_Click() Execute Me.hWND, "C:\Documents and Settings\Computer\Test.txt" End Sub Private Sub Command1_Click() Execute Me.hWND, "www.google.com" End Sub ![]() |
|
|
|
|
|
#10 |
|
Programmer
Join Date: Mar 2006
Posts: 36
Rep Power: 0
![]() |
Ah,I remember doing one of them when I started..
This is what I used Private Sub Command1_Click() Shell "notepad.exe" End Sub Private Sub Command1_Click() Shell "C:\WINNT\System32\calc.exe" End Sub Two examples of the way you can do it. Hope this helps, Reuben Keeney |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|