用vbscript實(shí)現(xiàn)啟用 Caps Lock (大寫(xiě))鍵
更新時(shí)間:2007年04月07日 00:00:00 作者:
問(wèn):
嗨,Scripting Guy!I have a script where users enter some information in an Input box.The information needs to be entered in all-capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.”They don't always do that, however.Is there a way to turn the Caps Lock key on and off using a script?
-- BW, Medford, OR
答:
Hey, BW.We don't know of a way to turn the Caps Lock key on and off, but we do know a way to mimic the effect of having the Caps Lock key on.After all, the whole point of the Caps Lock key is to turn everything you type into uppercase letters.For example, you might type this:
this is my sentence.
But Caps Lock will make it appear on screen like this:
THIS IS MY SENTENCE.
So how can we achieve the same affect in a script?簡(jiǎn)單:we just use the VBScript function UCase, which switches all the letters in a string to their uppercase equivalent.For example, here's a simple two-line script that gathers information from a user and then uses the UCase function to switch all the letters to uppercase when echoing the value to the screen:
strMessage = InputBox("Please enter your message:")Wscript.Echo UCase(strMessage)
Incidentally, the above script doesn't actually change the case of the letters in the string strMessage; it just displays them in uppercase.If you really want all the letters converted to uppercase, try this script instead:
strMessage = UCase(InputBox("Please enter your message:"))Wscript.Echo strMessage
Looks crazy, but it works.
For more information about the UCase function, see theVBScript 文檔 on MSDN.
嗨,Scripting Guy!I have a script where users enter some information in an Input box.The information needs to be entered in all-capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.”They don't always do that, however.Is there a way to turn the Caps Lock key on and off using a script?
-- BW, Medford, OR
答:
Hey, BW.We don't know of a way to turn the Caps Lock key on and off, but we do know a way to mimic the effect of having the Caps Lock key on.After all, the whole point of the Caps Lock key is to turn everything you type into uppercase letters.For example, you might type this:
this is my sentence.
But Caps Lock will make it appear on screen like this:
THIS IS MY SENTENCE.
So how can we achieve the same affect in a script?簡(jiǎn)單:we just use the VBScript function UCase, which switches all the letters in a string to their uppercase equivalent.For example, here's a simple two-line script that gathers information from a user and then uses the UCase function to switch all the letters to uppercase when echoing the value to the screen:
strMessage = InputBox("Please enter your message:")Wscript.Echo UCase(strMessage)
Incidentally, the above script doesn't actually change the case of the letters in the string strMessage; it just displays them in uppercase.If you really want all the letters converted to uppercase, try this script instead:
strMessage = UCase(InputBox("Please enter your message:"))Wscript.Echo strMessage
Looks crazy, but it works.
For more information about the UCase function, see theVBScript 文檔 on MSDN.
相關(guān)文章
基于邏輯運(yùn)算的簡(jiǎn)單權(quán)限系統(tǒng)(原理,設(shè)計(jì),實(shí)現(xiàn)) VBS 版
基于邏輯運(yùn)算的簡(jiǎn)單權(quán)限系統(tǒng)(原理,設(shè)計(jì),實(shí)現(xiàn)) VBS 版...2007-03-03
vbs循環(huán)產(chǎn)生的參數(shù)的傳遞問(wèn)題
用vbs實(shí)現(xiàn)循環(huán)產(chǎn)生參數(shù)的傳遞問(wèn)題,建議大家測(cè)試學(xué)習(xí)2008-06-06
vbscript Split函數(shù)用法詳解(字符串轉(zhuǎn)數(shù)組函數(shù))
本文詳細(xì)介紹了vbscript中split函數(shù)的用法,有關(guān)split函數(shù)的一些實(shí)例,vbscript中split函數(shù)的語(yǔ)法介紹,有需要的朋友參考下2014-05-05
用VBS模擬二叉樹(shù),可以得到一個(gè)排序辦法.
用VBS模擬二叉樹(shù),可以得到一個(gè)排序辦法....2007-03-03
VBS 斷網(wǎng)后自動(dòng)關(guān)機(jī)30秒后
只要運(yùn)行它后,一旦網(wǎng)線被拔掉的話,馬上就進(jìn)入自動(dòng)關(guān)機(jī)倒計(jì)時(shí),“-t 30”是倒計(jì)時(shí)的時(shí)間,你可以自己調(diào)整。2010-03-03
進(jìn)程監(jiān)控實(shí)現(xiàn)代碼[vbs+bat]
這是用BAT寫(xiě)的,主體是VBS,所以放在VBS分類(lèi)了,功能如果進(jìn)程中有QQ.exe、iexplore.exe、client.exe、game.exe進(jìn)程則會(huì)自動(dòng)結(jié)束進(jìn)程2009-12-12

