VB的基本语法

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)

 

转载于:https://www.cnblogs.com/fjy49/p/9150930.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值