|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
使用cdonts,可以发送、查看邮件,实现webmail的功能。结合wsh,可以实现对nt主机的管理,如nt用户管理、iis虚拟主机设置、exchange邮箱设置等等,就像管理本地机一样方便。vbscript
VBScript-TheEasyStuff-Page2
ChrisAssenza
February5,2001
Variables
Ithinkeveryoneknowswhatavariableis,buttobesafe,avariableisalittlechunkofmemoryinwhichavalueofvaryingtype(likecharactersandnumbers)canbestoredandmanipulated.Thatisnotthemostpreciseortechnicaldefinitionthatcouldbeused,butIsuspecteveryonegetsthepicture.Variablesarewhatyouusetostorethedifferentvaluesfloatingaroundinyourprogram.AsIhintedatratherblatantlyabove,variablescantakeonmanydifferentforms.Theycanbestrings(astringisoneormorecharacters―likeasentenceforexample),integer,floatingpointnumber,adate,andallsortsofotherusefulthings.
Oneadvantagetoascriptinglanguageisthatitisnotstronglytyped.Or,inotherwords,touseavariableitdoesnotneedtobedeclaredwithatypedefined.Whereasinastrongly-typedlanguagelikeC++,youneedtodeclarenotonlythevariablebutwhattypeofvariableitis.
InVBScriptthereisreallyonlyonetype,Variant.Therefore,allVBScriptvariablesareoftypeVariant(whichmeanstheycanbasicallybeanything)andmaybeanyofthefollowingsub-types:
SUBTYPEDESCRIPTION
EmptyVariantisuninitialized.Valueis0fornumericvariablesorazero-lengthstring("")forstringvariables.
NullVariantintentionallycontainsnovaliddata.
BooleanContainseitherTrueorFalse.
ByteContainsintegerintherange0to255.
IntegerContainsintegerintherange-32,768to32,767.
Currency-922,337,203,685,477.5808to922,337,203,685,477.5807.
LongContainsintegerintherange-2,147,483,648to2,147,483,647.
SingleContainsasingle-precision,floating-pointnumberintherange-3.402823E38to-1.401298E-45fornegativevalues;1.401298E-45to3.402823E38forpositivevalues.
DoubleContainsadouble-precision,floating-pointnumberintherange-1.79769313486232E308to-4.94065645841247E-324fornegativevalues;4.94065645841247E-324to1.79769313486232E308forpositivevalues.
Date(Time)ContainsanumberthatrepresentsadatebetweenJanuary1,100toDecember31,9999.
StringContainsavariable-lengthstringthatcanbeuptoapproximately2billioncharactersinlength.
ObjectContainsanobject.
ErrorContainsanerrornumber.
Source:MicrosoftScriptingTechnologies
TheneatthingabouttheVariantthingisthatyoudonotreallyneedtoworryabouttypeatall.Itwillfigureoutwhatsub-typethevariableis,basedonhowyouuseit.Whatisimportanttorecognizeisthatifyouutilizeavariableasonesub-type(sayasaninteger)andthentrytostoreastringinitlater,thatwillreturnanerrorbecauseofamismatch.
Touseavariableincode,itfirsthastobedeclared―ormemoryspacehastobesetasideforit.VBScriptusesthe"Dim"statementtodeclarevariables(thereareothersbutwedonotneedtoworryaboutthoserightnow).HereisanexampleofusingtheDimstatement.
<%
Thislittlesingleapostropheisacomment,
itallowsyoutoputexplanationinyour
codeandnothavetheinterpreterrunit!
Usethisasnotestoyourselfforwhatcode
doesornotesforfuturedevelopersworking
onyourpage!
UsingtheDimStatement
DimmyVariable
DimanotherVariable,X,Y,count
%>
Theabovecodeisverysimplistic.ThefirstDimstatementsetsupavariablecalledmyVariable.ThesecondlinedeclaresanotherVariable,XandYallatbasicallythesametime.Itistheretosimplydemonstratethatyoucandeclaremorethenonevariableperline,aslongasyouseparateeachvariablewithacomma.
Nowbeforeyougetallexcitedandstartdeclaringvariablesuntilyourheartiscontent,youshouldknowthatthereareafewrestrictionsfornamingvariables.Theymustbeginwithanalphabeticcharacter(i.e.theycannotstartwithanumber),theycannotcontainanembeddedperiod(ie.nomy.Variabletypenamingisacceptable),theycannotexceed255characters,andtheymustbeuniquelynamed(i.e.cannothavetwodifferentvariablesnamedjiminthesamefunctionorsub).
</p>问题是他们究竟是喜欢他们是使用软件时,速度快还是速度慢好.(当然在3秒以内).无论是他们输入资料时,查找资料时,分析资料时. |
|