點在visual basic開啟exe file?

2009-04-06 6:13 am
我在vb裹的user from 上建設了一個按鈕,請問我應該怎麼寫一個程式去利用這個按鈕來開啟exe file?

回答 (1)

2009-04-06 7:31 am
✔ 最佳答案
雙撃按鈕1:

在Private Sub CommandButton1_Click()下加一句
Call Shell("C:\WINDOWS\System32\calc.exe")
完成了.

###############################################
如果要傳回結果用程式1叫程式2

WindowsApplication1

======================================================
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Process.Start("C:\Documents and Settings\mithun\Local Settings\Application Data\Temporary Projects\WindowsApplication2\bin\Debug\WindowsApplication2.exe", "hello")

End Sub

End Class
===============

WindowsApplication2

===============

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim strParam As String

strParam = Command()

TextBox1.Text = "Command Line Argument Received Was " & strParam

End Sub

End Class

2009-04-05 23:37:36 補充:
Dim shell, fso
Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
shell.Run """C:\Program Files\Microsoft Office\Office10\WINWORD.exe"" file.doc"

2009-04-05 23:38:33 補充:
http://www.devdos.com/vb/lesson1.shtml

2009-04-05 23:43:55 補充:
http://forums.aspfree.com/visual-basic-programming-38/calling-external-exe-file-from-vb-code-34234.html
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
result = ShellExecute(Me.hwnd, "Open", "calc.exe", vbNullString, vbNullString

2009-04-05 23:45:41 補充:
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long

Private Sub cmdLaunchCalc_Click()
Dim result As Long


收錄日期: 2021-04-19 14:05:45
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090405000051KK02220

檢視 Wayback Machine 備份