课程设计说明书正文一、题目:计算器的创作和相应程序的编写二、本题的主要功能:通过计算器的创作熟悉各控件的属性和练习程序的编写。三、程序截图:四、源程序清单:BeginVB.FormForm1Caption=计算器ClientHeight=3765ClientLeft=165ClientTop=855ClientWidth=5355Icon=Form1.frx:0000LinkTopic=Form1LockControls=-1'TrueScaleHeight=3765ScaleWidth=5355StartUpPosition=3'窗口缺省BeginVB.CommandButtonCommand4Caption==Height=495Left=4470TabIndex=28Top=30601Width=735EndBeginVB.CommandButtonCommand3Caption=1/xHeight=495Left=4470TabIndex=27Top=2520Width=735EndBeginVB.CommandButtonCommand2Caption=%Height=495Left=4470TabIndex=26Top=1980Width=735EndBeginVB.CommandButtonCommand1Caption=sqrtHeight=495Left=4470TabIndex=25Top=1440Width=735EndBeginVB.CommandButtoncmbDOTCaption=.Height=495Left=2910TabIndex=24Top=3060Width=735End2BeginVB.CommandButtoncmbZFCaption=+/-Height=495Left=2130TabIndex=23Top=3060Width=735EndBeginVB.CommandButtoncmbSignCaption=+Height=495Index=3Left=3690TabIndex=22Top=3060Width=735EndBeginVB.CommandButtoncmbSignCaption=-Height=495Index=2Left=3690TabIndex=21Top=2520Width=735EndBeginVB.CommandButtoncmbSignCaption=*Height=495Index=1Left=3690TabIndex=20Top=1980Width=7353EndBeginVB.CommandButtoncmbSignCaption=/Height=495Index=0Left=3690TabIndex=19Top=1440Width=735EndBeginVB.CommandButtoncmbNUMCaption=9Height=495Index=9Left=2910TabIndex=18Top=1440Width=735EndBeginVB.CommandButtoncmbNUMCaption=8Height=495Index=8Left=2130TabIndex=17Top=1440Width=735EndBeginVB.CommandButtoncmbNUMCaption=7Height=495Index=7Left=1350TabIndex=164Top=1440Width=735EndBeginVB.CommandButtoncmbNUMCaption=6Height=495Index=6Left=2910TabIndex=15Top=1980Width=735EndBeginVB.CommandButtoncmbNUMCaption=5Height=495Index=5Left=2130TabIndex=14Top=1980Width=735EndBeginVB.CommandButtoncmbNUMCaption=4Height=495Index=4Left=1350TabIndex=13Top=1980Width=735EndBeginVB.CommandButtoncmbNUMCaption=3Height=495Index=35Left=2910TabIndex=12Top=2520Width=735EndBeginVB.CommandButtoncmbNUMCaption=2Height=495Index=2Left=2130TabIndex=11Top=2520Width=735EndBeginVB.CommandButtoncmbNUMCaption=1Height=495Index=1Left=1350TabIndex=10Top=2520Width=735EndBeginVB.CommandButtoncmbNUMCaption=0Height=495Index=0Left=1350TabIndex=9Top=3060Width=735EndBeginVB.CommandButtoncmbMaCaption=M+6Height=495Left=150TabIndex=8Top=3060Width=975EndBeginVB.CommandButtoncmbMSCaption=MSHeight=495Left=150TabIndex=7Top=2520Width=975EndBeginVB.CommandButtoncmbMRCaption=MRHeight=495Left=150TabIndex=6Top=1980Width=975EndBeginVB.CommandButtoncmbMCCaption=MCHeight=495Left=150TabIndex=5Top=1440Width=975EndBeginVB.CommandButtoncmbCCaption=CHeight=495Left=40207TabIndex=4Top=690Width=1155EndBeginVB.CommandButtoncmbCECaption=CEHeight=495Left=2670TabIndex=3Top=690Width=1155EndBeginVB.CommandButtoncmbbackspaceCaption=BackspaceHeight=495Left=1380TabIndex=2Top=690Width=1155EndBeginVB.TextBoxText1Alignment=1'RightJustifyHeight=375Left=210TabIndex=0Text=0.Top=120Width=4935EndBeginVB.LabelLabel2Alignment=2'CenterHeight=255Left=360TabIndex=298Top=840Width=375EndBeginVB.LabelLabel1Alignment=2'CenterBorderStyle=1'FixedSingleBeginPropertyFontName=宋体Size=14.25Charset=134Weight=400Underline=0'FalseItalic=0'FalseStrikethrough=0'FalseEndPropertyHeight=495Left=240TabIndex=1Top=690Width=615EndBeginVB.MenueditCaption=编辑(&E)EndBeginVB.MenulookCaption=查看(&V)EndBeginVB.MenuhelpCaption=帮助(&H)EndEndAttributeVB_Name=Form1AttributeVB_GlobalNameSpace=FalseAttributeVB_Creatable=False9AttributeVB_PredeclaredId=TrueAttributeVB_Exposed=FalseOptionExplicitPrivateDeclareFunctionShowCursorLibuser32(ByValbShowAsLong)AsLongDimdotflagAsBooleanDimfuhaoAsStringDimfirstAsDoubleDimsecondAsDoubleDimisEqualAsBooleanDimmemoryAsDouble'保存显示的数据DimlianyongAsDouble'当连续按等号时使用该变量PrivateDeclareFunctionShowCursorLibuser32(ByValbShowAsLong)AsLongDimdotflagAsBooleanDimfuhaoAsStringDimfirstAsDoubleDimsecondAsDoubleDimisEqualAsBooleanDimmemoryAsDouble'保存显示的数据DimlianyongAsDouble'当连续按等号时使用该变量PrivateSubcmbDesign_Click(IndexAsInteger)EndSubPrivateSubcmbbackspace_Click()IfRight(Trim(Text1.Text),1)=.ThenText1.Text=Mid(Text1.Text,1,Len(Text1.Text)-2)&.ElseText1.Text=Mid(Text1.Text,1,Len(Text1.Text)-1)EndIfIfRight(Text1.Text,1)=.Thendotflag=FalseEndIfIfLen(Text1.Text)=1ThenText1.Text=0.EndIfEndSub单击Backspace时删除文本框内最后一个字符10PrivateSubcmbC_Click()dotflag=FalseText1.Text=0.first=0second=0EndSub使文本框变成初始状态“0.”PrivateSubcmbCE_Click()Text1.Text=0.EndSub删除文本框内的所有内容,使文本框变成初始状态“0.”PrivateSubcmbDOT_Click()'标示点击了点“。”dotflag=TrueEndSub点的点击,PrivateSubcmbMa_Click()Text1.Text=Str(Val(Text1.Text)+memory)formatTextEndSub记忆运算数值PrivateSubcmbMC_Click()memory=0Label2.Caption=EndSub清除存储器内容.PrivateSubcmbMR_Click()Text1.Text=Str(memory)formatTextEndSub调用存储器内容PrivateSubcmbMS_Click()memory=Val(Text1.Text)'保存到内存中Label2.Caption=MEndSub保存到内存中PrivateSubcmbNUM_Click(IndexAsInteger)'判断是否按过等号键“=IfisEqual=TrueThenText1.Text=0.isEqual=False11EndIf'判断是否点击过“点”按扭,如果未点击过在点前添加,否则在点后添加Ifdotflag=FalseThenText1.Text=Left(Text1.Text,Len(Text1.Text)-1)&Index&.ElseText1.Text=Text1.Text&IndexEndIfformatTextEndSubPrivateSubcmbSign_Click(IndexAsInteger)'恢复未点击点“。”的状态dotflag=FalseisEqual=False'恢复等号在本次运算中未单击过状态first=Text1.Tex