打印

[提问] 求助~!!VB程序写不下去了!!

求助~!!VB程序写不下去了!!

当我的程序写到最后一步的时候,当我刚添加一个事件的时候,当我在事件下写入Shell "explorer.exe https://****.***.**/&protect_type=2"后,当我再运行的时候,当我点击这个事件时,它提示我“2不是有效网页”是怎么回事啊??

TOP

后缀名称限制为.htm;.asp;.jsp等等,这样的地址应该视为无效吧

TOP

不是啊!,上面的那个连接是不能变的,添加为地址之后就出错,怎样解决?

TOP

shell确实打开不了那种类型的地址。用api函数shellexecute可以解决这个问题 。
这是函数的声明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
使用方法p = ShellExecute(Me.hWnd, "open", " https://****.***.**/&protect_type=2", "", "", SW_SHOW)
的名义~~~~~~~~~~~~~~~

TOP

非常感谢楼上的,愿好人一生平安

TOP

那个&字符有问题,&在VB里是连接字符串用的,你找到他的ASCII码,用CHAR转换一下就行了,你写成 & CHAR(ASCII) &这样试一下,ASCII是&的ASCIH码,

TOP

你将shell "https://xxx.xxx.xxx/&protect_type=2"改成shell "https://xxx.xxx.xxx/" & char(38) & "protect_type=2"看一下

TOP

先谢谢楼上的了,回去试一下

TOP

今天发现个更简单的方法,只要给网址加个双重引号就可以了。
Shell "explorer.exe ""http://****.***.**/&protect_type=2"""
这样保证ok,比前面的简单多了。还有用chr(38)貌似不行的,chr函数在引号内不会执行,而shell却必须要有引号
的名义~~~~~~~~~~~~~~~

TOP

你把网址放在text1中,再用
shell "explorer.exe "+text1.text
试试

TOP

Processed in 0.383868 second(s), 5 queries, Gzip enabled.