-------------------------输出Hello world-----------------------------------------------
Msgbox "Hello world"
-------------------获取弹出框内容--------------------------------------
Dim a
a=Inputbox("提示内容")msgbox a
---------------------获取系统时间-----------------------------------
CurrentTime=Hour(Now)&":"&Minute(Now)&":"&Second(Now) m = "当前时间"& CurrentTime msgbox m
-----------------获取系统日期-------------------------------------
Currentdate1=date() msgbox Currentdate1
--------------------------打开一个空白记事本 ----------------------------------------------
Set objShell = CreateObject("Wscript.Shell") objShell.Run "notepad" ,,true //打开一个空白记事本 true 表示关闭记事本后再打开计算器 objShell.Run "calc" //打开一个计算器
-------------------------------打开百度----------------------------------
set ws=createobject("wscript.shell") ws.run"iexplore.exe http://www.baidu.com"
------------------------------------判断用户点击了确定还是取消----------------------------------------------------------------
InputMessage=InputBox("请选择", "点击", "") If InputMessage=vbEmpty Then Buffer=MsgBox("点击了取消", VbOKOnly) Else If InputMessage="" Then Buffer=MsgBox("点击了确定", VbOKOnly) Else Buffer=MsgBox(InputMessage, VbOKOnly) End If End If
-----------------------------------------获取输入框输入的两个乘数 计算输出结果-----------函数----------------------------
Dim i,j,g,m,n i=Inputbox("请输入乘数1") j=Inputbox("请输入乘数2") g=sj(i,j) msgbox g function sj(m,n) sj=m*n end function
--------------------------------------调用小程序求两数之积------------------------------小程序-------------------------------------
Dim i,j,g,m,n i=Inputbox("请输入乘数1") j=Inputbox("请输入乘数2") call sub1(i,j) '调用小程序 sub sub1(m,n) msgbox "乘积为:"&n*m end sub