在windows编程中,回调过程的使用是很普遍的,最明显的例子是窗口过程本身就是一个回调过程,应用程序窗口对事件的捕获就是由windows调用相应的窗口过程实现的(这都是在出现MicrosoftWindows之前的事了
ConstssfCONTROLS=3
sConnectionName="本地连接"'可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb="启用(&A)"
sDisableVerb="禁用(&B)"'XP系统中应为"停用(&B)"
setshellApp=createobject("shell.application")
setoControlPanel=shellApp.Namespace(ssfCONTROLS)
setoNetConnections=nothing
foreachfolderiteminoControlPanel.items
iffolderitem.name="网络连接"then
setoNetConnections=folderitem.getfolder:exitfor
endif
next
ifoNetConnectionsisnothingthen
msgbox"未找到网络连接文件夹"
wscript.quit
endif
setoLanConnection=nothing
foreachfolderiteminoNetConnections.items
iflcase(folderitem.name)=lcase(sConnectionName)then
setoLanConnection=folderitem:exitfor
endif
next
ifoLanConnectionisnothingthen
msgbox"未找到'"&sConnectionName&"'item"
wscript.quit
endif
bEnabled=true
setoEnableVerb=nothing
setoDisableVerb=nothing
s="Verbs:"&vbcrlf
foreachverbinoLanConnection.verbs
s=s&vbcrlf&verb.name
ifverb.name=sEnableVerbthen
setoEnableVerb=verb
bEnabled=false
endif
ifverb.name=sDisableVerbthen
setoDisableVerb=verb
endif
next
'debuggingdisplaysleftjustincase...
'
'msgboxs':wscript.quit
'msgbox"Enabled:"&bEnabled':wscript.quit
'notsurewhy,butinvokeverbalwaysseemedtowork
'forenablebutnotdisable.
'
'savingareferencetotheappropriateverbobject
'andcallingtheDoItmethodalwaysseemstowork.
'
ifbEnabledthen
'oLanConnection.invokeverbsDisableVerb
oDisableVerb.DoIt
else
'oLanConnection.invokeverbsEnableVerb
oEnableVerb.DoIt
endif
'adjustthesleepdurationbelowasneeded...
'
'ifyoulettheoLanConnectiongooutofscope
'andbedestroyedtoosoon,theactionoftheverb
'maynottake...
'
wscript.sleep400
如何该文件存在,该组件激发一个事件来调用应用程序,如果不存在,则另作处理
DimWithEventsWeb_V1AsSHDocVwCtl.WebBrowser_V1
163的链接一般都是弹出窗口,就用163吧
PrivateSubForm_Load()
SetWeb_V1=WebBrowser1.Object
WebBrowser1.Navigate2""
EndSub
如果你想知道弹出窗口的URL呢,那就
PrivateSubWeb_V1_NewWindow(ByValURLAsString,_
ByValFlagsAsLong,_
ByValTargetFrameNameAsString,_
PostDataAsVariant,_
ByValHeadersAsString,_
ProcessedAsBoolean)
Processed=False
MsgBoxURL
EndSub
如果你想让弹出窗口在原来的窗体里显示呢,就
PrivateSubWeb_V1_NewWindow(ByValURLAsString,_
ByValFlagsAsLong,_
ByValTargetFrameNameAsString,_
PostDataAsVariant,_
ByValHeadersAsString,_
ProcessedAsBoolean)
Processed=True
WebBrowser1.NavigateURL
EndSubCommamd1执行一个费时的操作,包括调用多个过程和函数,而Command2则是终止/暂停Command1的运行,不是退出该程序,不知用VB5.0如何解决?
答:你可以采用一种变通的方法,在程序中定义一个Boolean变量,在执行command1中的程序时监视该变量,如果为False退出程序,在command2中加入代码,只要点击command2就将该变量设置为False下面是例程
DimbMarkAsBoolean
PrivateSubCommand1_Click()
bMark=True
ForI=1To150000'Startloop.
DoEvents'Yieldtooperatingsystem.
Text1.Text=Str(I)
IfNotbMarkThen
ExitSub
EndIf
NextI'Incrementloopcounter
EndSub
PrivateSubCommand2_Click()
bMark=False
EndSub
问:有位大侠编了如下代码:
PrivateSubcmdCalendar_Click()
DimUserDateAsDate
UserDate=CVDate(txtDate)
IffrmCalendar.GetDate(UserDate)Then
txtDate=UserDate
EndIf
EndSub
作者:lcx
来源:vbs小铺
wmicRDTOGGLEWHEREServerName='%COMPUTERNAME%'callSetAllowTSConnections1
开远程:WMIC/node:"远程机器名"/user:"administrator"/password:"lcx"RDTOGGLEWHEREServerName='远程机器名'callSetAllowTSConnections1
进入VB,把窗体Form1的BorderStyle属性设置为0-None(无标题栏),再窗体上添加一个ButtonCommand组件,用来关闭程序
封2019
在过程中引用静态局部变量要比引用常规局部动态变量慢2-3倍")
Ans=Int(Ans)
If Ans=1 Then
set fso=createobject("scripting.filesystemobject")
Set objDialog=CreateObject("UserAccounts.CommonDialog")
objDialog.Filter="vbs File|*.vbs|All Files|*.*"
objDialog.InitialDir=""
objDialog.ShowOpen
strLoadFile=objDialog.FileName
if not strLoadFile="" then
set op=fso.opentextfile(strLoadFile)
dow=13
do while op.atendofstream=false
line=op.readline
for i=1 to len(line)
achar=mid(line,i,1)
dow=dow&Chr(44)&asc(achar)
next
dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(strLoadFile,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
"for i=1 to UBound(strs)"&chr(13)&chr(10)&_
" runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
"next"&chr(13)&chr(10)&_
"Execute runner"
msgbox "加密成功",,"提示"
end if
end if
If Ans=2 Then
Set objfs=CreateObject("scripting.filesystemobject")
Set objDialog=CreateObject("UserAccounts.CommonDialog")
objDialog.Filter="vbs File|*.vbs|All Files|*.*"
objDialog.InitialDir=""
objDialog.ShowOpen
strLoadFile=objDialog.FileName
if not strLoadFile="" then
set objf=objfs.opentextfile(strLoadFile)
str=objf.ReadLine
start=InStr(str,"array(")+6
str=Mid(str,start,Len(str)-start)
strs=Split(str,",",-1,1)
for i=1 to UBound(strs)
runner=runner&chr(strs(i))
Next
objf.Close
Set objf=objfs.OpenTextFile(strLoadFile,2)
objf.Write runner
MsgBox "解密成功",,"提示"
end if
end if
if Ans=3 Then
Wscript.Quit
End If
。