VB6 0點選按鈕自動開啟 EXE檔案

2022-06-12 17:21:42 字數 4213 閱讀 9192

1樓:小李無刀

你先要判斷檔案是否存在,用一個api即可,在模組裡宣告

private declare function pathfileexists lib "shlwapi.dll" alias "pathfileexistsa" (byval pszpath as string) as long

然後在按鈕裡寫上

if cbool(pathfileexists(sfile)) then msgbox "檔案不存在"

2樓:大漢伏波將軍

on error resume next 的意思是出現錯誤後繼續跳過錯誤繼續執行,當然沒反應了。你可以這麼寫

on error goto myerr

shell "c:\1.exe"

exit sub

myerr:

select case err.numbercase 53

msgbox"檔案不存在"

case else

msgbox"不明錯誤"

end select

或者不用api,直接用dir函式判斷有沒有檔案存在不就可以了,如下if dir("c:\1.exe")="" thenmsgbox"檔案不存在"

else

shell "c:\1.exe"

end if

vb6.0點選按鈕自動開啟一個.exe檔案

3樓:匿名使用者

例子:private sub command1_click()dim r as long

shellexecute函式原型及引數含義如下:

shellexecute(

hwnd: hwnd;

operation: pchar;

filename: pchar;

parameters: pchar;

directory: pchar;

showcmd: integer

): hinst;

//返回值可能的錯誤有: = 0

error_file_not_found = 2;

error_path_not_found = 3;

error_bad_format = 11;

se_err_share = 26;

se_err_associncomplete = 27;

se_err_ddetimeout = 28;

se_err_ddefail = 29;

se_err_ddebusy = 30;

se_err_noassoc = 31;

//showcmd 引數可選值:sw_hide = 0;

vb中單擊按鈕開啟某個軟體**是什麼

4樓:匿名使用者

shell("你所要開啟資料夾的路徑")

5樓:匿名使用者

比如開啟c:\tencent\qq.exeprivate sub command1_click()shell "c:\tencent\qq.exe" ,引數end sub

引數懂一點英文就可以看懂,就是執行的軟體視窗以及是否有焦點

6樓:匿名使用者

shell "軟體名"

7樓:悠悠周郎

shell "路徑\程式名"

8樓:匿名使用者

很多種方法!最簡單的shell方法!

9樓:匿名使用者

private sub command1_click()

shell "c:\windows\regedit.exe"

end sub

10樓:我tm不管

shell "calc.exe"

如何做單擊vb的一個命令按鈕開啟某一個檔案?

11樓:匿名使用者

用cmd 開啟檔案:

shell "cmd.exe /c start "+chr(34)+chr(34)+" "+chr(34)+"你的檔案路徑"+chr(34),vbhide

有效防止shell打不開除exe以外格式的程式。

12樓:卡卡少佐

做程式的是不是都太複雜了,是不是可以直接shell「貼上exe程式源地址」,是不是就好了,那麼複雜,但是移動了原始檔,這個命令就失效了

13樓:匿名使用者

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

private const sw_shownormal = 1開啟:shellexecute 0, "open", "c:\1.

txt", "", vbnullstring, sw_shownormal

"c:\1.txt", ""

分別為檔案路徑和執行引數(一般是exe)

vb 6.0 如何在編寫的程式內部開啟exe程式

14樓:網海1書生

下面是以記事本為例:

private declare function setparent lib "user32" (byval hwndchild as long, byval hwndnewparent as long) as long

private declare function findwindow lib "user32" alias "findwindowa" (byval lpclassname as string, byval lpwindowname as string) as long

private sub command1_click()

dim h as long

shell "notepad", vbnormalnofocus    '開啟記事本

doh = findwindow(vbnullstring, "無標題 - 記事本") '找到記事本的視窗控制代碼

doevents

loop while h = 0   '如果未找到就繼續迴圈

setparent h, me.hwnd    '把記事本的視窗設為自身視窗的子視窗

end sub

值得說明的是:執行後可能會一下子在form1中看不到記事本的視窗,這是因為記事本視窗的初始位置不一定是在螢幕的左上角,所以到了form1中它也會在窗體偏右和偏下的位置,只要把form1最大化就看到了,再把記事本拖到適合的位置就行了。

vb6 0 退出整個for迴圈用 exit for退出本

private sub command1 click dim i as integer,j as integerfor i 1 to 3 if i 2 then goto a 當i 2時,退出本次循專環屬 for j 1 to 3 print i j next j a next i end sub ...

vb60要求編寫function過程在文字框中輸入

寫了一段,窗 bai體上放du一個text,一個按鈕zhi,如下 daofunction sushu a as integer as integer for i 2 to a 1 step 1if a mod i 0 then msgbox a 不為素數 vbinformation vbokonly...

VB裡怎樣實現點選命令按鈕就使Filelistbox裡的檔案被選中

file1.listindex 0 filelistbox 是排序的 無法自定義位置 vb中怎麼實現點選一次一個命令按鈕使第一個文字框輸出一個東西,然後過幾秒第二個文字框再輸出一個東西?知道菌!哼哼!option explicit private sub command1 click text1.t...