和成一条命令 我刚学 弄不明白了 下边是我的10条命令
Public Sub bBt1_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 1))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 1
End If
End Sub
Public Sub bBt2_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 2))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 2
End If
End Sub
Public Sub bBt3_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 3))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 3
End If
End Sub
Public Sub bBt4_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 4))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 4
End If
End Sub
Public Sub bBt5_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 5))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 5
End If
End Sub
Public Sub bBt6_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 6))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 6
End If
End Sub
Public Sub bBt7_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 7))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 7
End If
End Sub
Public Sub bBt8_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 8))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 8
End If
End Sub
Public Sub bBt9_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 9))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 9
End If
End Sub
Public Sub bBt0_Click()
If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + 0))
Else
flag = nflag
nflag = ""
a = Val(F001.text1.Text)
F001.text1.Text = 0
End If
End Sub
vb 简单四则运算 怎么把0到9的数赋值的时候
使用数组 添加一个按钮控件,然后复制粘贴,会提示你是否创建为数组,选择是,然后双击按钮写代码(注,先将你的原来按钮的代码删去),然后开始添加如下代码 注意:index表示数组的,在属性页可修改,以下代码中bBt1(0)表示按钮0,bBtn1(1)表示按钮1,后同 Private Sub bBt1_Click(Index As Integer)...
如何用VB做一个简单计算器 要求实现加减乘除乘方开方功能
Begin VB.CommandButton Command9 Caption = "退格" Height = 375 Left = 1920 TabIndex = 18 Top = 480 Width = 495 End Begin VB.CommandButton Command8 Caption = "清零" Height = 375 Left = 2520 TabIndex = 17 Top = 480 Width = 495 End Begin VB.CommandButton cmdDot Caption = "." ...
VB设计“加减乘除计算器”谢谢大家,计算器最好是带负数和小数的...
Text1.Text = StrNum1 第四章 按钮(二)下面会复杂一些,我们先跳过等号,而来处理四则运算:先在General里声明新变量:Dim Runsign As Integer '储存运算符号 Dim SignFlag As Boolean '判断是否已有运算符号 然后在Form_Load中进行初赋值:Runsign = 0 SignFlag = False 在接下的Command1_Click...
vb中如何将一个四则运算的符号赋值给变量
不能直接赋值,是通过间接地。将运算符赋值给一个字符串变量,通过条件语句进行转化成相应的四则运算操作。例如 sub form_click()dim f as string dim a as integer ,b as integer a = 3 b = 5 f = InputBox("请输入运算符")select case f case "+"c = a+b case "-"c = a-...
简易计算器的VB代码解释(要求比较详细,满意后再追加分数)
Dim FirstNumber, NumbumBuf As Double Private Sub Command1_Click(Index As Integer) '0到9 ch = Format(Index, "0") '原来使用val函数是错误的!那个是把字符串转换成数值。本来要使用str函数,但他的结果总是有数字前面一位空格,所以使用这个了。If Text1.Text = "0" Then Text1.Text ...
用VB制作任意多个多位数的四则运算,求高手
If Y = 0 Then MsgBox "除数不能为0", 16, "错误!"Exit Sub End If Text1.Text = X \/ Y End If X = Val(Text1.Text)Else MsgBox "操作数不足!", 16, "错误!"End If End Sub Private Sub Command4_Click()Text1.Text = "": X = 0: Y = 0: FH = ""End Sub Priva...
vb 溢出的问题
VB进行加减乘除四则运算时,会根据第一步运算时的位数来决定最终结果的存储位数。这个跟最终赋值的那个变量是什么类型是无关的,因为这是发生在运算过程中(也就是赋值之前)的。所以 16384 * 4 * 0.5 由于16384是Integer,所以VB会先假定运算结果也是Integer,因此它就分配两个字节的内存空间来存储...
VB中Label1.Caption = CStr(Int(Rnd() * 10)) 是什么意思啊
Label1.Caption = CStr( Int( Rnd() * 10 ) )在0到9这10个数数中取一个随机数——x 返回小于等于x的最大整数——y 将y转换为 String 数据类型——z 将z赋值给Label1的Caption属性 既Label1的显示字符为z
求助:很简单的关于long型VB溢出的问题。。。
是这样的:VB在进行四则运算前,会先根据参与运算的各个数值的类型来预先决定用什么类型的数值来保存运算结果(注意这跟运算结果赋值给什么类型的变量是没有关系的,因为上述过程发生在赋值前),而4000和10都是整型数(Integer),所以VB就自作聪明地按整型运算的方式来处理运算结果,但是实际运算结果...
VB中文本内公式的计算问题
如果公式是1+2=形式,则:Dim a As Integer Private Sub Command1_Click()a = Val(Left(Text1.Text, 1)) + Val(Right(Text1.Text, 2))Text2.Text = a End Sub如果公式是1+2形式,则:Dim a As Integer Private Sub Command1_Click()a = Val(Left(Text1.Text, 1)) + Val(Right...