加减乘除html代码vb,VB6.0的加减乘除代码是什么?

Num2 As Double

Dim Equal As Double

Dim M As Double

Dim Equal2 As Integer

Dim StrNum1 As String

Dim StrNum2 As String

Dim FirstPoint As Boolean

Dim FirstNum As Boolean

Private Sub Command1_Click(Index As Integer) '数字输入

Select Case Index

Case 0 To 9

StrNum1 = LTrim(StrNum1) LTrim(Str(Index))

Do While Left(LTrim(StrNum1), 1) = "0" '去掉高位数字0

StrNum1 = Mid(StrNum1, 2)

Loop

If Left(LTrim(StrNum1), 1) = "。

" Then StrNum1 = "0" LTrim(StrNum1)

Text1。Text = StrNum1 '数字显示

Case 10

If FirstPoint Then '小数点的输入

StrNum1 = LTrim(StrNum1) LTrim("。

")

Do While Left(LTrim(StrNum1), 1) = "0" '去掉高位数字0

StrNum1 = Mid(StrNum1, 2)

Loop

If Left(LTrim(StrNum1), 1) = "。

" Then StrNum1 = "0" LTrim(StrNum1)

Text1。Text = StrNum1 '数字显示

FirstPoint = False

Text1。

Text = StrNum1

End If

Case 11

StrNum1 = Text1。Text '退格

If Len(StrNum1) > 0 Then

StrNum1 = Left(StrNum1, Len(StrNum1) - 1) '每一次退格,从字符串后面去掉一个字符

Text1。

Text = StrNum1

Else

Text1。Text = "0。0"

End If

If InStr(StrNum1, "。") = 0 Then FirstPoint = True '若字符串中没有小数点,把小数点开关打开

Case 12 '清零

StrNum1 = ""

StrNum2 = ""

Text1。

Text = "0。0"

aa = ""

Equal = 0

Num1 = 0

Num2 = 0

FirstPoint = True '小数点开关

FirstNum = True '第一个数开关

Case 13 '正负符号

If Val(StrNum1) > 0 Then

StrNum1 = "-" LTrim(StrNum1)

Else

StrNum1 = Abs(Val(StrNum1))

End If

Text1。

Text = StrNum1

Case 14 '电源开关

End

End Select

End Sub

Private Sub Command2_Click(Index As Integer) ' -*/运算

Equal2 = Index '=号开关

If FirstNum Then '存第一个数,其中FirstNum为开关

StrNum2 = StrNum1

StrNum1 = ""

FirstNum = False

FirstPoint = True '小数点开,以便输入第二个数

Else '若不是第一个数进入下面的 -*/运算

Select Case Index

Case 0 '0为加法

Num1 = Val(StrNum2) 'Num1存第一个数

Num2 = Val(StrNum1) 'Num2存第二个数

Equal = Num1 Num2 'Equal存结果

StrNum2 = Str(Equal) 'StrNum2返回结果,以便下次让Num1存结果

StrNum1 = "" 'StrNum1清空,以便下次数字输入

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa '显示结果

FirstPoint = True '小数点开

Case 1 '1为减法

Num1 = Val(StrNum2)

Num2 = Val(StrNum1)

Equal = Num1 - Num2

StrNum2 = Str(Equal)

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

Case 2 '为乖法

Num1 = Val(StrNum2)

If StrNum1 = "" Then '便于 -*/之间切换

Num2 = 1

Else

Num2 = Val(StrNum1)

End If

Equal = Num1 * Num2

StrNum2 = Str(Equal)

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

Case 3 '3为除法

Num1 = Val(StrNum2) 'Num1存第一个数

If StrNum1 = "" Then

Num2 = 1

Else

Num2 = Val(StrNum1)

End If

Equal = Num1 / Num2

StrNum2 = Str(Equal) 'Num2存第二个数

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

End Select

End If

End Sub

Private Sub Command3_Click() '=号运算

FirstNum = True '第一个数关,关掉连继 -*/

Select Case Equal2 'Equal2为=号按键判断 -*/哪种运算

Case 0 ' 运算

If StrNum2 = "" Then

Num1 = Equal

Else

Num1 = Val(StrNum2)

End If

Num2 = Val(Text1。

Text)

Equal = Num1 Num2

StrNum1 = "" '返回结果

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa '显示结果

FirstPoint = True '小数点开

Case 1 '-运算

If StrNum2 = "" Then

Num1 = Equal

Else

Num1 = Val(StrNum2)

End If

Num2 = Val(Text1。

Text)

Equal = Num1 - Num2

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

Case 2 '*运算

If StrNum2 = "" Then

Num1 = Equal

Else

Num1 = Val(StrNum2)

End If

If StrNum1 = "" Then

Num2 = 1

Else

Num2 = Val(Text1。

Text)

End If

Equal = Num1 * Num2

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

Case 3 '/运算

If StrNum2 = "" Then

Num1 = Equal

Else

Num1 = Val(StrNum2)

End If

If StrNum1 = "" Then

Num2 = 1

Else

Num2 = Val(Text1。

Text)

End If

Equal = Num1 / Num2

StrNum1 = ""

aa = Str(Equal)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

FirstPoint = True

End Select

End Sub

Private Sub Command4_Click() '开方运算

aa = Val(Text1。

Text)

StrNum1 = ""

If aa >= 0 Then

aa = Str(Sqr(aa))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。

Text = aa

Else

MsgBox "被开方数少于零"

End If

End Sub

Private Sub Command7_Click() '倒数运算

aa = Val(Text1。

Text)

StrNum1 = ""

aa = Str(1 / aa)

If Left(LTrim(aa), 1) = "-" And Left(LTrim(aa), 2) = "-。

" Then aa = "-0" LTrim(Abs(Equal))

If Left(LTrim(aa), 1) = "。" Then aa = "0" LTrim(aa)

Text1。Text = aa

End Sub

Private Sub Command8_Click(Index As Integer) '存贮器操作

Select Case Index

Case 0 'MC,存贮器清零

Text2。

Text = ""

M = 0

Case 1 'MR,显示存贮器内容。

全部

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值