Option Explicit '強制聲明變量
'變量的定義
'Dim Opera,Operb,result
'常量的定義
'Const vbPI=3.14
'Opera=InputBox("please input a's value")
'Operb=InputBox("please input b's value")
'result=Opera+Operb
'MsgBox Opera&"+"&Operb&"="&result
'MsgBox vbPI
'內置換行
'MsgBox "hello"&vbCrLf&"world"
'字符串,大小寫轉換
'Dim x
'x=LCase("aBc") '小寫
'MsgBox x
'x=UCase("Abcc") '大寫
'MsgBox x
'StrComp 比較字符 如果字符相同則返回結果為0,否則為非0
'Dim username,inun
'username="zhangsan"
'inun=InputBox("請輸入用戶名")
' If StrComp(username,inun) Then
' MsgBox "用戶名不相同"
' Else
' MsgBox "相同"
' End If
'字符長度
' Dim a
' a="maiziedu"
' MsgBox Len(a)
'字符串替換
'Dim astr
'astr=Replace("hello,xiaoyu","hello","hi")
'MsgBox astr
'字符串分割
'Dim teststr,teststrs
'teststr="2.1.3"
'teststrs=Split(teststr,".")
' MsgBox teststrs(0)
' MsgBox teststrs(1)
' MsgBox teststrs(2)
