您的位置:程序门 -> vb -> 基础类



计算器算不出结果~代码好像没错~进来看看


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


计算器算不出结果~代码好像没错~进来看看
发表于:2007-01-25 12:53:37 楼主
option   explicit
        dim   equalsym   as   boolean
        dim   pointsym   as   boolean
        dim   firstnum   as   double
        dim   computetype   as   string
       
private   sub   cmdaddpiture_click()
        cdl.dialogtitle   =   "´ò¿ªò»·ùí¼æ¬ "
        cdl.action   =   1
        picview.picture   =   loadpicture(cdl.filename)
        picview.visible   =   true
end   sub

private   sub   cmdnumber_click(index   as   integer)
      if   equalsym   =   true   then   'èç¹ûóðëã꽸õëãí꣬ðèòªòôïâ²ù×÷
            txtoutput.text   =   " "         'çå¿õïô꾿òäúµä½á¹û
            equalsym   =   false   '°ñ±êê¾·ûequalsymµäöµ»¹ô­
        end   if
    txtoutput.text   =   txtoutput.text   &   trim(str(index))
end   sub


private   sub   cmdcompute_click(index   as   integer)
      firstnum   =   val(txtoutput.text)
      txtoutput.text   =   " "
      select   case   index
            case   0       '¼ó·¨ôëëã
                    computetype   =   "add "
            case   1       '¼õ·¨ôëëã
                    computetype   =   "subtraction "
            case   2       '³ë·¨ôëëã
                    computetype   =   "multiplication "
            case   3       '³ý·¨ôëëã
                    computetype   =   "division "
        end   select
        equalsym   =   false   '°ñ±êê¾·û¡°equalsym¡±µäöµ»¹ô­
        pointsym   =   false   '°ñ±êê¾·û¡°pointsym¡±µäöµ»¹ô­
end   sub

private   sub   cmdpoint_click()
        if   pointsym   =   false   then
            if   txtoutput.text   =   " "   then   txtoutput.text   =   "0 "
            txtoutput.text   =   txtoutput.text   &   ". "
            pointsym   =   true
        end   if
       
end   sub


private   sub   cmdnegative_click()
          txtoutput.text   =   trim(str(-val(txtoutput.text)))
end   sub

private   sub   cmdclear_click()
      txtoutput.text   =   " "
      pointsym   =   false
end   sub

private   sub   cmdequal_click()
        if   equalsym   =   false   then
              select   case   computetype
                        case   "add "
                              txtoutput.text   =   str(firstnum   +   val(txtoutput.text))
                        case   "subtraction "
                              txtoutput.text   =   str(firstnum   -   val(txtoutput.text))
                        case   "multiplication "
                              txtoutput.text   =   str(firstnum   *   val(txtoutput.text))
                        case   "division "
                              txtoutput.text   =   str(firstnum   /   val(txtoutput.text))
                end   select
                equalsym   =   true
        end   if
    pointsym   =   false
    end   sub

private   sub   form_load()
    equalsym   =   false
    pointsym   =   false
end   sub
和例子的一样,但是例子的=算的出结果。我的=算不到..按了没反应~
发表于:2007-01-25 12:54:471楼 得分:0
怎么有乱玛的??晕了~神啊.9958~!


快速检索

最新资讯
热门点击