VB程序设计计算器.docx

上传人:b****8 文档编号:10231285 上传时间:2023-02-09 格式:DOCX 页数:13 大小:80.35KB
下载 相关 举报
VB程序设计计算器.docx_第1页
第1页 / 共13页
VB程序设计计算器.docx_第2页
第2页 / 共13页
VB程序设计计算器.docx_第3页
第3页 / 共13页
VB程序设计计算器.docx_第4页
第4页 / 共13页
VB程序设计计算器.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

VB程序设计计算器.docx

《VB程序设计计算器.docx》由会员分享,可在线阅读,更多相关《VB程序设计计算器.docx(13页珍藏版)》请在冰豆网上搜索。

VB程序设计计算器.docx

VB程序设计计算器

2.3属性设置

窗体和各控件的属性设置如下表所示

2.4系统功能

本系统的主要功能及任务是

1.简单计算

2.科学计算

2.5系统功能模块图

一.界面设计。

对象属性设置

对象名

属性

Form1

Caption

科学计算器

Command3

Caption

Sin

index

0

Command3

Caption

cos

index

1

Command3

Caption

tg

index

2

Command3

Caption

sec

index

3

Command3

Caption

csc

index

4

Command3

Caption

ctg

index

5

Comman3

Caption

Sqr

index

6

Command3

Caption

1/a

index

7

Command3

Caption

arctg

index

8

Command3

Caption

arcctg

index

9

Command3

Caption

log

index

10

Command3

Caption

ln

index

11

Command3

Caption

sh

index

12

Command3

Caption

ch

index

13

Command3

Caption

abs

index

14

Command1

Caption

0

index

0

Command1

Caption

1

index

1

Command1

Caption

2

index

2

Command1

Caption

3

index

3

Command1

Caption

4

index

4

Command1

Caption

5

index

5

Command1

Caption

6

index

6

Command1

Caption

7

index

7

Command1

Caption

8

index

8

Command1

Caption

9

index

9

Command2

Caption

-

index

10

Command2

Caption

.

index

11

Command2

Caption

+

index

12

Command2

Caption

-

index

13

Command2

Caption

*

index

14

Command2

Caption

/

index

15

Command4

Caption

index

16

Command4

Caption

index

17

Command4

Caption

退出

index

18

Command4

Caption

Delete

Command5

Caption

Back

Command5

Caption

=

第三章

详细设计

3.1窗体

3.2程序代码

PublicsumAsDouble

PublickAsString

PublicpiAsDouble

PubliccAsDouble

PublicdAsDouble

PublicnAsDouble

FunctionLog10(X)

Log10=Log(X)/Log(10)

EndFunction

FunctionLogn(X)

Logn=Log(X)/Log(n)

EndFunction

PrivateSubcheck_Click()

Shell"C:

\WINDOWS\explorer.exe

EndSub

PrivateSubCommand1_Click(IndexAsInteger)

SelectCaseIndex

Case1

Text1.Text=Text1.Text&1

Case2

Text1.Text=Text1.Text&2

Case3

Text1.Text=Text1.Text&3

Case4

Text1.Text=Text1.Text&4

Case5

Text1.Text=Text1.Text&5

Case6

Text1.Text=Text1.Text&6

Case7

Text1.Text=Text1.Text&7

Case8

Text1.Text=Text1.Text&8

Case9

Text1.Text=Text1.Text&9

Case0

Text1.Text=Text1.Text&0

Case10

Text1.Text=Text1.Text&"."

EndSelect

EndSub

PrivateSubCommand2_Click(IndexAsInteger)

SelectCaseIndex

Case0

sum=Text1.Text

Text1.Text=""

k="+"

Case1

sum=Text1.Text

Text1.Text=""

k="-"

Case2

sum=Text1.Text

Text1.Text=""

k="*"

Case3

sum=Text1.Text

Text1.Text=""

k="/"

EndSelect

EndSub

PrivateSubCommand3_Click()

DimaAsDouble

a=Text1.Text

Ifk="+"Then

sum=sum+a

Text2.Text=sum

ElseIfk="-"Then

sum=sum-a

Text2.Text=sum

ElseIfk="*"Then

sum=sum*a

Text2.Text=sum

ElseIfk="/"Then

sum=sum/a

Text2.Text=sum

ElseIfk="sin"Then'等号的三角计算

sum=Sin(a*pi/180)

Text2.Text=sum

ElseIfk="cos"Then

sum=Cos(a*pi/180)

Text2.Text=sum

ElseIfk="tan"Then

sum=Tan(a*pi/180)

Text2.Text=sum

ElseIfk="cot"Then

sum=1/(Tan(a*pi/180))

Text2.Text=sum

ElseIfk="lg"Then'等号的lg计算

sum=Log(Val(Text1.Text))

Text2.Text=sum

ElseIfk="ln"Then'等号的ln计算

sum=Log10(Val(Text1.Text))

Text2.Text=sum

ElseIfk="logn"Then'等号的logna计算

sum=Logn(Val(Text1.Text))

Text2.Text=sum

ElseIfk="2"Then'等号的幂函数计算

sum=(Val(Text1.Text))^2

Text2.Text=sum

ElseIfk="c"Then

sum=Val(Text1.Text)^c

Text2.Text=sum

ElseIfk="0.5"Then'等号的开方运算

sum=(Val(Text1.Text))^0.5

Text2.Text=sum

ElseIfk="d"Then

sum=(Val(Text1.Text))^(1/d)

Text2.Text=sum

EndIf

EndSub

PrivateSubCommand4_Click(IndexAsInteger)

DimbAsInteger

b=Len(Text1.Text)

Ifb>1Then

Text1.Text=Val(Str(Left(Text1.Text,Len(Text1.Text)-1)))

Else

Text1.Text=""

EndIf

EndSub

PrivateSubCommand5_Click()

Text1.Text=""

Text2.Text=""

Label2.Caption=""

Label3.Caption=""

a=0

b=0

k=""

EndSub

PrivateSubCommand6_Click(IndexAsInteger)

SelectCaseIndex

Case0

Label2.Caption="sin"

k="sin"

Case1

Label2.Caption="cos"

k="cos"

Case2

Label2.Caption="tan"

k="tan"

Case3

Label2.Caption="cot"

k="cot"

Case4'对数计算

Label2.Caption="lg"

k="lg"

Case5

Label2.Caption="ln"

k="ln"

Case6

n=Val(InputBox("请输入对数运算的底数",请输入数字))

Label2.Caption="log"'普通对数计算

Label4.Caption=n

k="logn"

Case7'幂运算

Label3.Caption="2"

k="2"

Case8

c=Val(InputBox("请输入运算幂指数",输入数字))

Label3.Caption=c

k="c"

Case9'幂运算

Label2.Caption="√"

k="0.5"

Case10'开方运算

d=Val(InputBox("请输入需要开多少次方",输入数字))

Label2.Caption=d&"√"

k="d"

EndSelect

EndSub

PrivateSubCommand7_Click()

Shell"C:

\WINDOWS\explorer.exe"

EndSub

PrivateSubCommand8_Click()

Text1.Text=sum

EndSub

PrivateSubCommand9_Click()

End

EndSub

PrivateSubend_Click()

End

EndSub

PrivateSubexplain_Click()

EndSub

PrivateSubForm_Load()

pi=4*Atn

(1)

EndSub

PrivateSubhelp_Click()

EndSub

PrivateSubText1_Change()

EndSub

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 哲学历史

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1