我正在为朋友创建一个visual basic应用程序。无论如何,我试图创建一个函数,返回“退出子”到调用该函数的子。通过返回一个像1或2这样的值并在调用sub中插入if,我已经看到了一些方法。只是想知道是否有一个我还没有学过的退出子手的短手。
Private Sub Button1.click() Handles Button1.Click
tryactive()
endsub
Private Function tryactive()
Try
AppActivate("your aplication")
Catch ex As Exception
Dim msgboxresponse = MsgBox("please start your application", 0, "Can't find your application")
If msgboxresponse = MsgBoxResult.Ok Then
Exit Sub <------ this is the problem i want to send this back to calling sub
End If
End Try
End Function
代码更大,按钮更多。这就是为什么我问是否有更好的方法来做到这一点。任何帮助表示赞赏。
答案 0 :(得分:4)
首先,您无法在 功能 中使用 退出子 。它应该是 退出函数 。但根据你想要发生的事情(我猜),试试这个。
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>