Vbscript 如何使用vb脚本创建单选按钮?
我想在我的电脑上设定时间。为此,我编写了三个不同国家的3个单选按钮的脚本,以便用户可以通过选择其中一个单选按钮来设置时区 另外,请在以下错误中提供帮助:Vbscript 如何使用vb脚本创建单选按钮?,vbscript,automation,Vbscript,Automation,我想在我的电脑上设定时间。为此,我编写了三个不同国家的3个单选按钮的脚本,以便用户可以通过选择其中一个单选按钮来设置时区 另外,请在以下错误中提供帮助: Set objExecObject = objShell.Exec("tzutil.exe /s """ & TimeZoneFriendlyName & "") WScript.Echo "Setting the time zone sucessfully." 你的报价也错了Cmd/k将允许您查看Cmd中发生的情况,并
Set objExecObject = objShell.Exec("tzutil.exe /s """ & TimeZoneFriendlyName & "")
WScript.Echo "Setting the time zone sucessfully."
你的报价也错了Cmd/k
将允许您查看Cmd中发生的情况,并在其工作后将其删除
WScript.CreateObject("WScript.Shell").Run "cmd /k tzutil.exe /s """ & TimeZoneFriendlyName & """"
这是一个HTA,显示单选按钮、复选框、按钮,并显示如何实现键盘访问
<HTML>
<HEAD><TITLE>Search</TITLE>
<HTA:APPLICATION ID="oMyApp"
APPLICATIONNAME="Search"
BORDER="normal"
BORDERSTYLE="sunken"
CONTEXTMENU="yes"
CAPTION="yes"
ICON="C:\windows\system32\shell32,-5"
SCROLL="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
/>
<style>
BODY {font-size :100%;font-family: Arial, Helvetica, sans-serif;color: black;
background:URL(images/watermark.gif);background-color: white;
margin-top:20pt; margin-left:40pt; margin-right:10pt ; text-align:Justify}
P {margin-left:0pt;margin-right:0pt}
</style>
<SCRIPT LANGUAGE="VBScript">
Dim Searchterm
Sub Search
' On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
If tb2(5).Checked=True then WshShell.Run "https://www.google.com/maps/place/" & Replace(tb1.value, " ", "+")
If tb2(4).Checked=True then WshShell.Run "https://www.google.com/search?q=" & Replace(tb1.value, " ", "+") & "&cr=countryAU"
If tb2(3).Checked=True then WshShell.Run "https://www.google.com/search?q=site:msdn.com+" & Replace(tb1.value, " ", "+")
If tb2(2).Checked=True then WshShell.Run "https://www.google.com/search?q=nethack+" & Replace(tb1.value, " ", "+")
If tb2(1).Checked=True then WshShell.Run "https://en.wikipedia.org/wiki/" & tb1.value
If tb2(0).Checked=True then WshShell.Run "https://www.google.com/search?q=" & Replace(tb1.value, " ", "+")
WshShell.RegWrite "HKCU\Software\StackOverflow\VBS\Searchterm", tb1.value & vbtab & WshShell.RegRead("HKCU\Software\StackOverflow\VBS\Searchterm")
If tb3.checked=true then window.close
End Sub
Sub Init
Count = 0
window.resizeTo 550, 400
' On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
HistoryArr = Split(WshShell.RegRead("HKCU\Software\StackOverflow\VBS\Searchterm"), Chr(9))
tb1.value = HistoryArr(0)
For each t in HistoryArr
Count=Count + 1
Set Hist = document.createElement("OPTION")
Hist.Text=t
Hist.Value=Count
HistoryList.Add(Hist)
Count=Count + 1
If Count > 50 then exit For
next
tb1.select
' tb1.focus
End Sub
Sub Paste
tb1.value=document.parentwindow.clipboardData.GetData("TEXT")
tb1.select
End Sub
Sub LBTransfer
x = CLng(HistoryList.Options.selectedindex)
tb1.value = HistoryList.Options(x).text
tb1.select
End Sub
Sub LBTransferK
x = CLng(HistoryList.Options.selectedindex)
tb1.value = HistoryList.Options(x).text
HistoryList.focus
End Sub
</script>
</head>
<body Onload=Init>
<p><b>Enter <u>s</u>earch term</b></p>
<p><INPUT Name=tb1 TYPE=Text size=60 AccessKey=s> <INPUT Type=Button onclick=paste Value=Paste AccessKey=p></p>
<p><b><u>H</u>istory</b></p>
<p><SELECT NAME="HistoryList" SIZE="4" Onclick=LBTransfer OnKeyPress=LBTransferK AccessKey=h>
</SELECT></p>
<p><b>Search <u>w</u>here</b></p>
<p><INPUT Name=tb2 TYPE=RADIO CHECKED AccessKey=w> Google <INPUT Name=tb2 TYPE=RADIO> Wikipedia <INPUT Name=tb2 TYPE=RADIO> Nethack <INPUT Name=tb2 TYPE=RADIO> MSDN <INPUT Name=tb2 TYPE=RADIO> Australia <INPUT Name=tb2 TYPE=RADIO> Maps </p>
<p><INPUT NAME="Search" TYPE="SUBMIT" VALUE="Search" OnClick=Search> <INPUT Name=tb3 TYPE=CHECKBOX CHECKED AccessKey=c> <u>C</u>lose on search</p>
</body>
</html>
搜寻
正文{字体大小:100%;字体系列:Arial,Helvetica,无衬线;颜色:黑色;
背景:URL(images/watermark.gif);背景颜色:白色;
上页边距:20页;左页边距:40页;右页边距:10页;文本对齐:对齐}
P{左边距:0pt;右边距:0pt}
模糊搜索词
子搜索
'出现错误时,请继续下一步
设置WshShell=CreateObject(“WScript.Shell”)
如果tb2(5).Checked=True,则WshShell.Run“https://www.google.com/maps/place/替换(tb1.value,“,”+”)(&Replace)
如果tb2(4).Checked=True,则WshShell.Run“https://www.google.com/search?q=替换(tb1.value,“,”+”&“&cr=countryAU)”(&R)
如果tb2(3).Checked=True,则WshShell.Run“https://www.google.com/search?q=site:msdn.com+替换(tb1.value,“,”+”)(&Replace)
如果tb2(2).Checked=True,则WshShell.Run“https://www.google.com/search?q=nethack+替换(tb1.value,“,”+”)(&Replace)
如果tb2(1).Checked=True,则WshShell.Run“https://en.wikipedia.org/wiki/“&tb1.value”
如果tb2(0).Checked=True,则WshShell.Run“https://www.google.com/search?q=替换(tb1.value,“,”+”)(&Replace)
WshShell.RegWrite“HKCU\Software\StackOverflow\VBS\Searchterm”,tb1.value&vbtab&WshShell.regrad(“HKCU\Software\StackOverflow\VBS\Searchterm”)
如果tb3.checked=true,则window.close
端接头
亚初始
计数=0
window.resizeTo 550400
'出现错误时,请继续下一步
设置WshShell=CreateObject(“WScript.Shell”)
HistoryArr=Split(WshShell.regrad(“HKCU\Software\StackOverflow\VBS\Searchterm”),Chr(9))
tb1.value=历史ARR(0)
对于历史中的每一个t ARR
计数=计数+1
Set Hist=document.createElement(“选项”)
历史文本=t
历史值=计数
历史列表。添加(历史)
计数=计数+1
如果计数>50,则退出以进行计数
下一个
tb1.选择
“tb1.focus
端接头
子粘贴
tb1.value=document.parentwindow.clipboardData.GetData(“文本”)
tb1.选择
端接头
子传输
x=CLng(HistoryList.Options.selectedindex)
tb1.value=HistoryList.Options(x).text
tb1.选择
端接头
子LBK
x=CLng(HistoryList.Options.selectedindex)
tb1.value=HistoryList.Options(x).text
历史焦点
端接头
输入搜索词
历史
搜索哪里
谷歌维基百科网络黑客MSDN澳大利亚地图
接近搜索
不能使用VBscript创建单选按钮。您将需要使用HTA或其他包装器
错误似乎是由于您没有设置shell对象造成的
所以使用
Set objExecObject = objShell.Exec("tzutil.exe /s """ & TimeZoneFriendlyName & "")
WScript.Echo "Setting the time zone sucessfully."
你首先要有一个
Set objShell = CreateObject("Wscript.Shell")
在此之前VB.NET不是vba,也不是vbscript欢迎使用StackOverflow。我们很想帮助你,但是1)听起来你有两个问题(还有)你的第一个问题是什么?2) 如果你确实有两个问题,请分别发帖。3) 不要将错误发布为图像;发布错误的文本。您可以编辑您的问题(通过单击问题下的“编辑”链接),希望得到更好的答案。
objShell
需要包含一个WshShell
对象,使用Set-objShell=WScript.CreateObject(“WScript.Shell”)
Set objExecObject = objShell.Exec("tzutil.exe /s """ & TimeZoneFriendlyName & "")
WScript.Echo "Setting the time zone sucessfully."
Set objShell = CreateObject("Wscript.Shell")