VBscript 中的语言基础

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
WScript.Echo "hello world. "
' show the content
Dim a,b,c
'  set varibles
a=1
b=2
c=a+b
WScript.Echo c
' show the answer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
' enforce us to set varibles before we use it.
Dim a,b
a=2
b=3
c=a+b
WScript.Echo c
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
' enforce us to set varibles before we use it.
Dim a,b,c
a="2nihao"
b="3"
c=a+b
WScript.Echo "c=",c,a,b
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'to change the type of varibles

sumA = 30:sumB=15
Test=CBool(sumA=sumB)
WScript.Echo Test

sumB=sumB*2
Test=CBool(sumA=sumB)
WScript.Echo Test

dateStr="December 10,2005"
theDate=CDate(dateStr)
WScript.Echo theDate

timeStr="8:25:10 AM"
theTime=CDate(timeStr)
WScript.Echo theTime

aDouble=715.234
bDouble=33.24
cDouble=aDouble+bDouble
WScript.Echo aDouble
WScript.Echo cDouble 
aString =CStr(aDouble)
WScript.Echo aString

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'How to use Arrays in programming

Option Explicit

Dim bookArray(10)

bookArray(0)="A Tale of Two Cities"
bookArray(1)="Grapes of Wrath"

Wscript.Echo bookArray(0)
Wscript.Echo bookArray(1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim bookArray()


'you can change the capacity of the Arrays again
reDim bookArray(5)
bookArray(0)="A Tale of Two Cities"
bookArray(1)="Grapes of Wrath"

Wscript.Echo bookArray(0)
Wscript.Echo bookArray(1)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' the operators in VBScirpt
answer=9Mod3
WScript.Echo answer
answer=9Mod2
WScript.Echo answer
answer=9^2
WScript.Echo answer
answer=-9*2
WScript.Echo answer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' the operators in VBScirpt
answer=9 Mod 3
WScript.Echo answer
answer=9 Mod 2
WScript.Echo answer
answer=9^2
WScript.Echo answer
answer=-9*2
WScript.Echo answer
answer=-9+2*10
WScript.Echo answer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值