用vbscript实现启用 Caps Lock (大写)键

   2015-11-13 0
问:
嗨,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?简单: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.
 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

点击排行