当前位置:首页 >> 其它课程 >>

Vb常用内部函数练习题加答案


1、 编写一个计算器,在 text1 和 text2 中输入数字,text3 中输出结果。实现的功能为“加、 减、乘、除、绝对值、符号函数、平方根函数、取余、乘方、负号、整除”

2、 编写一个程序,在 text1 中输入,text2 中输出结果。实现的功能为“int(x) 、asc(x) 、 chr(x) 、val(s) 、str(s) ”

3、 编写一个程序,在 text1 中输入一个身份证号码,先去除该数字前的空格(ltrim(s) ) 从该身份证号码中截取此身份证号码的出生年月日

4、 编写以一下程序,实现如下的效果

5、 编写一个程序, 在 text1 和 text2 中输入一串字符开始查找, 如果 text2 中找到 text1 中的 字符,text3 返回位置,如果找不到 text3 则返回 0

6、 编写一个程序,在 text1 中输入一段英文语句,text2 中返回其大写或小写

7、 编写一个程序,获取当前系统时间

8、 编写一个随机函数,产生 1-20 之间的 5 组随机函数,且第二次初始化时不能重复出现

答案
1、Private Sub Command1_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a + b End Sub Private Sub Command10_Click() Text3.Text = Sgn(Text3.Text) End Sub Private Sub Command11_Click() Text3.Text = Sqr(Text3.Text) End Sub

Private Sub Command2_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a - b End Sub Private Sub Command3_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a * b End Sub Private Sub Command4_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a / b End Sub Private Sub Command5_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a Mod b End Sub Private Sub Command6_Click() Dim a As Single Dim b As Single a = Text1.Text b = Text2.Text Text3.Text = a \ b End Sub Private Sub Command7_Click() Dim a As Single Dim b As Single a = Text1.Text

b = Text2.Text Text3.Text = a ^ b End Sub Private Sub Command9_Click() Dim a As Single Text3.Text = Abs(Text3.Text) End Sub 2、Private Sub Command1_Click() Dim a As Single a = Text1.Text Text2.Text = Int(a) End Sub Private Sub Command2_Click() Dim a As String a = Text1.Text Text2.Text = Asc(a) End Sub Private Sub Command3_Click() Dim a As String a = Text1.Text Text2.Text = Chr(a) End Sub Private Sub Command4_Click() Dim a As Single a = Text1.Text Text2.Text = Str(a) End Sub Private Sub Command5_Click() Dim a As String a = Text1.Text Text2.Text = Val(a) End Sub 3、Private Sub Command1_Click() Dim a As String Dim b As String a = Text1.Text b = LTrim(a) Text2.Text = Mid(b, 7, 6) End Sub

4、Private Sub Form_Click() Print String(1, "*") Print String(2, "*") Print String(3, "*") Print String(4, "*") Print String(5, "*") Print String(6, "*") Print String(6, "*") Print String(5, "*") Print String(4, "*") Print String(3, "*") Print String(2, "*") Print String(1, "*") End Sub 5、Private Sub Command1_Click() Dim a As String Dim b As String a = Text1.Text b = Text2.Text Text3.Text = InStr(a, b) End Sub 6、Private Sub Command1_Click() Dim a As String a = Text1.Text Text2.Text = LCase(a) End Sub Private Sub Command2_Click() Dim a As String a = Text1.Text Text2.Text = UCase(a) End Sub 7、Private Sub Command1_Click() Dim a As String Text1.Text = Now() End Sub 8、Private Sub Form_Click() Dim a As Integer Dim b As Integer a=1 b = 20 Randomize Print Int((b - a) * Rnd + a); Int((b - a) * Rnd + a); Int((b - a) * Rnd + a); Int((b - a) * Rnd + a); Int((b a) * Rnd + a)

End Sub


赞助商链接
相关文章:
_VB常用内部函数
VB 我们准备了很多常用的内部函数,供我们在编程时...主 要有输入函数 Input 和输出函数 Msgbox,下面将...的标题,它是可以省 略的,如果缺省,该对话框的题...
【VB6.0】VB常用术语内部函数
【VB6.0】VB常用术语内部函数_计算机软件及应用_IT/计算机_专业资料。【VB6.0】VB 常用术语/内部函数常用术语 项目(Project):是用户创建的文件集合,这个集合包括...
VB函数汇总
VB函数汇总_计算机软件及应用_IT/计算机_专业资料。...---2 我吐血整理的常用内部函数!(献给像我一样的...CInt(4.5) 你猜个答案,再运行看看结果 作者: pig...
VB简介
这一版本使 VB 功能得到了很大扩充 和增强。 ...它实际上是在对象类中定义一些成员函数,类 似...要想寻求一个正确的答案,绝非一件易事,幸运是 ...
更多相关标签: