没有合适的资源?快使用搜索试试~ 我知道了~
VB常用命令范例.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 129 浏览量
2022-06-26
09:21:51
上传
评论
收藏 133KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/85780985/0001-b144452d991c0b0171ba626e4dc7ea35_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
20页
VB常用命令范例.doc
资源推荐
资源详情
资源评论
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![xsl](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/release/download_crawler_static/85780985/bg1.jpg)
目录
字体代码 文本框限制命令
IF … THEN … ELSE
倒计时器代码
SELECT CASE
IF … THEN … ELSEIF
F or …… next
D o……loop
W hile …… weng
字符识别 文本框选定 大写字母密文
三个静态数组 动态数组
F or Each … Next
T ype …… End Type
Form1.windowstate = 2
最大化
Form1.windowstate = 0
还原
Form1.windowstate = 1
最小化
Left = -2000
隐藏,用于无线钮
Form*.show
加载新窗体
Unload me
卸载现在的窗体
Load
加载窗体或控件但不显示
Stop
暂停程序的运行
End
结束程序运行
字体代码
BackColor = RGB(255, 255, 255)
ForeColor = RGB(0, 0, 255)
FontName = "楷体_gb2312"
FontSize = 20
FontBold = True
FontItalic = True
FontUnderline = True
FontStrikethru = True
CurrentX = 1200
CurrentY = 350
Print "回乡偶书(贺知章)"
FontName = "宋体"
Print
FontSize = 13
'背景色为白色
'前景色为蓝色,字体颜色
'字体名
'字号
'粗体
'斜体
'下划线
'删除线
'从此横坐标开始打印
'从此纵坐标开始打印
'字体名
'字号
![](https://csdnimg.cn/release/download_crawler_static/85780985/bg2.jpg)
Print Spc(6); "少小离家老大回,乡音无改鬓毛衰。"
Print
Print Spc(6); "儿童相见不相识,笑问客从何处来。"
文本框限制命令
Private Sub Command1_Click()
If Textxm = "" Then
Textxm.SetFocus
Exit Sub
End If
End Sub
假如文本框为空那么
把这个文本设为焦点
退出这段命令
Private Sub Textdh_LostFocus()
If Textdh.Text <> "" Then
If Len(Textdh.Text) <> 8 Or Not
IsNumeric(Textdh.Text) Then
Textdh.Text = ""
Textdh.SetFocus
End If
End If
End Sub
当焦点离开文本框时执行
假如文本框不为空那么
假如输入内容不满 8 个字节且内容不
是数字类型
把此文本框清空
设此文本框为焦点
Private Sub Textxb_LostFocus()
If Textxb.Text <> "" Then
If Textxb.Text <> "男" And Textxb.Text <> "女"
Then
Textxb.Text = ""
Textxb.SetFocus
End If
End If
End Sub
假如文本框内容不为男或女
IF…THEN…ELSE
Dim h As Integer, a As Date
Show
h = Hour(Time)
FontSize = 30
fontcolor = RGB(255, 0, 0)
BackColor = RGB(255, 255, 0)
If h < 12 Then
Print "早上好!"
Else
If h < 18 Then
Print "下午好!"
Else
![](https://csdnimg.cn/release/download_crawler_static/85780985/bg3.jpg)
Print "晚上好!"
End If
End If
End Sub
IF…THEN…ELSEIF
Private Sub cmdjs_Click()
Dim a As Double, b As Double, c As Double, d
As Double, e As Double, f As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
f = c - 2000
If f <= 0 Then
d = 0
ElseIf f <= 500 Then
d = f * 5 / 100
ElseIf f <= 2000 Then
d = (f - 500) * 10 / 100 + 25
ElseIf f <= 5000 Then
d = (f - 2000) * 15 / 100 + 175
ElseIf f <= 20000 Then
d = (f - 5000) * 20 / 100 + 625
ElseIf f <= 40000 Then
d = (f - 20000) * 25 / 100 + 3625
ElseIf f <= 60000 Then
d = (f - 40000) * 30 / 100 + 8625
ElseIf f <= 80000 Then
d = (f - 60000) * 35 / 100 + 14625
ElseIf f <= 100000 Then
d = (f - 80000) * 40 / 100 + 21625
Else
d = (f - 100000) * 45 / 100 + 29625
End If
e = c - d
Text3.Text = d
Text4.Text = e
End Sub
这是多分支的条件语句,该语句执行时先测
试条件 1,如果为假,依次测试条件 2,以
此类推,直到找到为真的条件,一旦找到一
个为真的条件,则执行相应的语句块,然后
执行 end if 后面的语句代码,如果所有的条
件都为假,则执行 else 后面的语句块,然后
执行 end if 后面的代码。
SELECT CASE
Case 表达式 1
语句块 1
Case 表达式 2
表达式通常是指一个具体
值,
每一个值确定一个分支
![](https://csdnimg.cn/release/download_crawler_static/85780985/bg4.jpg)
语句块 2
Case else
语句块 n
End select
一组值(用逗号隔开)
Case 1,3,5
表示在条件在 1,3,5 之中取
值
表达式 1 to 表达式 2
Case 60 to 80
表示条件取值范围为 60~80
Is 关系式
Case is<5
表示条件在小于 5 的范围内
取值
本语句执行时先计算表达式的值,然后依次与结构中的每个 case 的值进行比较,如果该值
符合某个 case 指定值的条件,执行该 case 的语句块,然后跳到 end select 出口语句,如果
没有相符合的 case 语句值,执行 case else 中的语句块。
Dim cj As Single, temp As String
cj = Text1.Text
temp = "成绩等级为:"
Select Case cj
Case Is < 0
Label2.Caption = "成绩出错"
Case Is < 60
Label2.Caption = temp & "不及格"
Case Is < 80
Label2.Caption = temp & "及格"
Case Is < 90
Label2.Caption = temp & "良好"
Case Is <= 100
Label2.Caption = temp & "优秀"
Case Else
Label2.Caption = "成绩出错"
End Select
Select Case True
Case no = h(m)
flag = m
Text2.Text = h(m)
Text3.Text = d(m, 1)
Text4.Text = d(m, 2)
Text5.Text = (d(m, 1) + d(m, 2)) / 2
Case no < h(m)
bott = m - 1
Case no > h(m)
top = m + 1
End Select
倒计时器代码
剩余19页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/acfce43ffe2c41f996326bd927946824_yhsbzl.jpg!1)
智慧安全方案
- 粉丝: 3707
- 资源: 59万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)