2022年风铃科学计算器程序代码 .pdf
《2022年风铃科学计算器程序代码 .pdf》由会员分享,可在线阅读,更多相关《2022年风铃科学计算器程序代码 .pdf(14页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、风铃计算器程序代码青春风铃西南交通大学名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 14 页 -Dim sum As Double,Expr,A,B,D,Cha As String Dim Time As Integer Dim leftbracket,rbracket As Integer Dim Bo1,Bo2,Sto As Boolean 名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 14 页 -Public Function Fact(n As Long)As Double If n 0 Then If n=1 Then Fact=1 Else Fact
2、=n*Fact(n-1)End If ElseIf n=0 Then Fact=1 Else If n=-1 Then Fact=-1 Else Fact=n*Fact(n+1)End If End If End Function Private Function leftfind(ByV al Expr As String,Where As Long)As String Dim i,leftbracket,rbracket As Integer Dim numl As String If Mid(Expr,Where-1,1)=)Then-左有括号For i=Where To 1 Step-
3、1 If Mid(Expr,i,1)=)Then rbracket=rbracket+1 ElseIf Mid(Expr,i,1)=(Then lbracket=lbracket+1 End If If lbracket=rbracket And lbracket 0 Then numl=Mid(Expr,i,Where-i)Exit For End If Next i Else-无括号For i=Where-1 To 1 Step-1 numl=Mid(Expr,i,1)If numl=+Or numl=-Or numl=*Or numl=/Or numl=(Then numl=Mid(Ex
4、pr,i+1,Where-i-1)Exit For End If If i=1 Then numl=Mid(Expr,1,Where-1)Exit For 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 14 页 -End If Next i End If leftfind=numl End Function Private Function rightfind(ByV al Expr As String,Where As Long)As String Dim i,leftbracket,rbracket As Integer Dim numr As String If Mid(
5、Expr,Where+1,1)=(Then-右有括号For i=Where+1 To Len(Expr)If Mid(Expr,i,1)=)Then rbracket=rbracket+1 ElseIf Mid(Expr,i,1)=(Then lbracket=lbracket+1 End If If lbracket=rbracket And lbracket 0 Then numr=Mid(Expr,Where+1,i-Where)Exit For End If Next i Else-无括号For i=Where+1 To Len(Expr)numr=Mid(Expr,i,1)If nu
6、mr=+Or numr=-Or numr=*Or numr=/Or numl=(Then numr=Mid(Expr,Where+1,i-Where-1)Exit For End If If i=Len(Expr)Then numr=Mid(Expr,Where+1,i-Where)Exit For End If Next i End If rightfind=numr End Function Private Sub jingdian_Click(Index As Integer)Frame1.BackColor=&H8080FF Frame2.BackColor=&H80FF80 Fram
7、e3.BackColor=&HFF80FF Text2.BackColor=&H80FF80 For i=0 To 11 Label1(i).BackColor=&HFF80FF Next i 名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 14 页 -jingdian(0).Enabled=False chuantong(1).Enabled=True pinhong(2).Enabled=True End Sub Private Sub chuantong_Click(Index As Integer)Frame1.BackColor=&H8000000F Frame2.Ba
8、ckColor=&H8000000F Frame3.BackColor=&H8000000F Text2.BackColor=&H8000000F For i=0 To 11 Label1(i).BackColor=&H8000000F Next i jingdian(0).Enabled=True chuantong(1).Enabled=False pinhong(2).Enabled=True End Sub Private Sub pinhong_Click(Index As Integer)Frame1.BackColor=&HFF80FF Frame2.BackColor=&HFF
9、80FF Frame3.BackColor=&HFF80FF Text2.BackColor=&HFF80FF For i=0 To 11 Label1(i).BackColor=&HFF80FF Next i jingdian(0).Enabled=True chuantong(1).Enabled=True pinhong(2).Enabled=False End Sub Private Sub Form_Load()A=0:B=0:D=0 Sto=False:Bo=False Text1.Text=0 Text2.Text=青春风铃欢迎您的使用!jingdian(0).Enabled=F
10、alse End Sub-状态栏代码-Private Sub Frame1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=数字键 End Sub 名师资料总结-精品资料欢迎下载-名师精心整理-第 5 页,共 14 页 -Private Sub Frame2_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=运算符
11、End Sub Private Sub Frame3_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=功能区,选中Shift 时执行附加功能End Sub Private Sub Command4_MouseMove(Index As Integer,Button As Integer,Shift As Integer,X As Single,Y As Single)Select Case Index Case 0 StatusBar1.Panels(2
12、).Text=退格 Case 1 StatusBar1.Panels(2).Text=清除 Case 2 StatusBar1.Panels(2).Text=左括号 Case 3 StatusBar1.Panels(2).Text=右括号 Case 4 StatusBar1.Panels(2).Text=等于号 End Select End Sub Private Sub Text1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=风铃计算表达式 End
13、 Sub Private Sub Text2_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=风铃计算结果 End Sub Private Sub Check1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=功能转换键 End Sub Private Sub Check2_MouseMove(Button As
14、Integer,Shift As Integer,X As Single,Y As Single)StatusBar1.Panels(2).Text=选中为角度模式,否则为弧度模式 End Sub-数字键的输入-Private Sub Command1_Click(Index As Integer)If Time 1 Then 名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 14 页 -Text1.Text=清空表达式Time=1 End If If Index=9 Then Text1.Text=Text1.Text&Index ElseIf Index=10 Then Tex
15、t1.Text=Text1.Text&.Else Text1.Text=Text1.Text&pi End If End Sub-运算符的输入-Private Sub Command2_Click(Index As Integer)If Time=0 Then Text1.Text=ElseIf Time=2 Then Text1.Text=Ans End If Time=1 Select Case Index Case 0 Text1.Text=Text1.Text&+Case 1 Text1.Text=Text1.Text&-Case 2 Text1.Text=Text1.Text&*Ca
16、se 3 Text1.Text=Text1.Text&/End Select End Sub-函数功能的输入-Private Sub Command3_Click(Index As Integer)-前处理-If Index=2 Or(Index=8 And Check1.Value=0)Then If Time=2 Then Text1.Text=Ans 引用结果End If Else If Time 1 Then Text1.Text=清空表达式End If End If 名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 14 页 -附加功能-If Check1.Value=0
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年风铃科学计算器程序代码 2022 风铃 科学 计算器 程序代码
限制150内