简单科学计算器vb程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

’//本人写的原始程序

'注意没法实现如下功能:10+===然后输入10再=。此程序会结果出错

Dim denghao, fenghao As Boolean 'denghao判断是否按下“=”,fenghao判断是否按下“1/X”Dim xiaoshu, biaoji As Boolean 'xiaoshu判断是否已按“.”,biaoji第一次判断前面是否按过“+”“-”等运算符按钮

Dim fuhao As Byte '运算符类型标号

Dim leixin As Byte '进制转换类型

Dim fistnumber, last As Double 'fistnumber第一个数据,最后一个数据

Dim panduan, jinzhi As Boolean 'panduan判断前面是否连续按“+”“-”等运算符按钮

Dim denglianxu As Boolean 'denglianxu判断前面是否连续安"="

Dim m, n, i, sum As Double

Dim pi As Double 'sin,cos

Dim kuahao As Boolean '判断是否按下“(”

Dim si As String

Dim shilu, bajin As Boolean '十六进制下才能输入A-F;八进制下8-9不能输入

Dim h, d, o, b As Integer '进制

Dim se, s As Double

Dim ejin As Boolean '判断2-9,在二进制下不能输入

Private Sub baifeng_Click() '1/X的程序

If Not biaoji Then

fuhao = 7

If Val(Text1.Text) = "0" Then

Text1.Text = "除数不能为零"

Else

Call jieguo

End If

Else

Call jieguo

fuhao = 7

Call jieguo

End If

fenghao = True

xiaoshu = False

End Sub

Private Sub clear_Click()

If clear.Value = 1 Then Text1.Text = "0"

xiaoshu = False

clear.Value = 0

sum = 1

biaoji = False

panduan = False

denghao = False

last = 0

fistnumber = 0

denglianxu = False

X = 0

si = ""

i = 0

sum = 0

shilu = False

bajin = False

ejin = False

End Sub

Private Sub Command11_Click() '+/-号

Text1.Text = -1 * Val(Text1.Text)

If Left(Val(Text1.Text), 1) = "." Then Text1.Text = "0" + Text1.Text If Left(Val(Text1.Text), 2) = "-." Then

Text1.Text = -1 * Val(Text1.Text)

Text1.Text = "-0" + Text1.Text

End If

panduan = True

denglianxu = False

denghao = True

End Sub

Private Sub Command0_Click()

If Text1.Text = "0" Then

Text1.Text = 0

ElseIf Not denghao And Not fenghao Then

If Not kuahao Then Text1.Text = Text1.Text + "0"

Else

Text1.Text = "0"

denglianxu = False

fenghao = False

denghao = False

panduan = False

End If

End Sub

Private Sub Command1_Click()

If Text1.Text = "0" Then Text1.Text = ""

If Not denghao And Not fenghao Then

If Not kuahao Then Text1.Text = Text1.Text + "1" Else

Text1.Text = "1"

denglianxu = False

fenghao = False

denghao = False

panduan = False

kuahao = False

End If

End Sub

Private Sub Command2_Click()

If Text1.Text = "0" Then Text1.Text = ""

If ejin Then

MsgBox "请输入二进制数"

Text1.Text = 0

Exit Sub

End If

If Not denghao And Not fenghao Then

If Not kuahao Then Text1.Text = Text1.Text + "2" Else

Text1.Text = "2"

fenghao = False

denghao = False

panduan = False

denglianxu = False

kuahao = False

End If

End Sub

相关文档
最新文档