改进版计算器?
这个是我那个简易计算器的改进版 参照了各位大牛的各种好意见 写出来的帮忙看看有什么可以改进的地方 类模板做的是否合理
程序代码:**************************************************
*-- 主函数
SET CLOCK on
SET TALK OFF
frmMain = CREATEOBJECT("C_Form")
frmMain.show
READ events
RETURN
*
*-- 程序结束
**************************************************
**************************************************
*-- 类: C_Form (d:\vfp\td\12.vcx)
*-- 父类: form
*-- 基类: form
*-- 时间戳: 09/15/16
DEFINE CLASS C_Form as Form
_screen.minbutton = .f.
_screen.MaxButton = .f.
_screen.Closable = .f.
caption = "简单计算器"
width = 600
height = 400
autocenter = .T.
ADD OBJECT LT1 as LT WITH sub_label.caption = "第一个数",;
top = 100,;
left = thisform.width/2 - thisform.LT1.width - 10
ADD OBJECT LT2 as LT WITH sub_label.caption = "第二个数",;
top = thisform.LT1.top,;
left = thisform.width/2 + 10
ADD OBJECT LT3 as LT WITH sub_label.caption = "第三个数",;
top = ThisForm.LT1.TOP + 100,;
Left = ThisForm.Width/2 + 10
ADD OBJECT com_box as ComboBox WITH height = 20, width = 50,;
top = ThisForm.LT3.top, left = ThisForm.width/2 - ThisForm.LT3.width - 10
ADD OBJECT exit_one as commandbutton WITH top = thisform.LT3.top + 100, left = 50, width = 100,;
height = 25, caption = "退出"
PROCEDURE init
WITH = 2
.rowsource = [+,-,*,/,@]
.rowsourcetype = 1
.value = 5
ENDWITH
ENDPROC
PROCEDURE exit_one.click
a = MESSAGEBOX("真的要退出吗", 1 + 32, "确认")
IF a == 1
CLEAR EVENTS
ELSE
RETURN
ENDIF
ENDPROC
PROCEDURE com_box.interactivechange
IF !EMPTY(thisform.LT1.sub_text.value) .and. !EMPTY(thisform.LT2.sub_text.value)
IF ALLTRIM() == '/' .and. VAL(thisform.LT2.sub_text.value) == 0
MESSAGEBOX("除数不能为零")
RETURN
ELSE
IF > 4 .or. < 1
MESSAGEBOX("错误的计算方式")
RETURN
ELSE
kk = ALLTRIM(thisform.LT1.sub_text.value) + ALLTRIM();
+ ALLTRIM(thisform.LT2.sub_text.value)
thisform.LT3.sub_text.value = ALLTRIM(STR(&kk, 10, 2))
ENDIF
ENDIF
ENDIF
ENDPROC
ENDDEFINE
*
*-- EndDefine: C_Form
**************************************************
**************************************************
*-- 类: LT (d:\vfp\td\12.vcx)
*-- 父类: container
*-- 基类: container
*-- 时间戳: 09/15/16
*
#INCLUDE "d:\vfp\vfp\foxpro.h"
*
DEFINE CLASS LT AS container
Width = 160
Height = 25
Name = "LT"
ADD OBJECT sub_label AS label WITH ;
Caption = "", ;
Height = this.Height, ;
Left = 0, ;
Top = 0, ;
Width = 60, ;
Name = "sub_label"
ADD OBJECT sub_text AS textbox WITH ;
Height = this.Height, ;
Left = This.sub_label.Left + this.sub_label.width, ;
Top = 0, ;
Width = 100, ;
Name = "sub_text"
ENDDEFINE
*
*-- EndDefine: LT
************************************************** 顺便发个图[ 本帖最后由 有容就大 于 2012-9-16 14:15 编辑 ]







