问题如下:
      回数:(        )   <--这是个imText控件
      金额:(       )  <--这是个imText控件
      总金额:<        >   <-- 这是个label只要回数和金额有值(0也可以),,当光标无论是在回数还是在金额imText里面,总金额label总能及时自动根据回数和金额里面的值算出总金额是多少,当回数和金额其中任何一个没有值时,则总金额里面的值是空。
具体怎么实现请大家帮忙看看,具体用到什么事件方法请帮忙写写看,最好有代码。急。

解决方案 »

  1.   

    晕闷,能继续说清楚,或者抓图上来么imtext是你自己的控件?
      

  2.   

    可用textbox控件的change控件来实现:
    '写一个自动计算的过程
    private sub AutoCal()
       if trim(text1.text)<>"" and trim(text2.text)<>"" then
           if isnumeric(text1.text) and isnumeric(text2.text) then
               label1.caption=cdbl(text1.text)*cdbl(text2.text)
           else
               label1.caption=""
           end if
       else
           label1.caption=""
       end if
    end subprivate sub text1_change()
       call autocal
    end sub
    private sub text2_change()
       call autocal
    end sub
      

  3.   

    问一下!
    isnumeric 和 cdbl 是什么函数?
    程序写的不错,当我认为要对Change()事件判断输入是否为数字!
      

  4.   

    isnumeric()判断是否为数值型数据的函数
      

  5.   

    isnumeric就是判断是否是数字的函数!
      

  6.   

    回数:(        )   Text1
    金额:(       )  Text2
    总金额:<        >   label1sub text1_change()
    if not isnumeric(text1.text) then text1.text=""
    If trim(text1.text)<>"" and trim(text2.text)<>"" then
       label1.caption=val(text1.text) + val(text2.text)
    endif
    end subsub text2_change()
    if not isnumeric(text2.text) then text2.text=""
    If trim(text1.text)<>"" and trim(text2.text)<>"" then
       label1.caption=val(text1.text) + val(text2.text)
    endif
    end sub就这样可以了。
      

  7.   

    如果楼主使用控件数组:
    回数:(        )   Text1(0)
    金额:(       )  Text1(1)
    总金额:<        >   label1sub text1_change(Index as integer)
    if not isnumeric(text1(index).text) then text1(Index).text=""
    If trim(text1(0).text)<>"" and trim(text1(1).text)<>"" then
       label1.caption=val(text1(0).text) + val(text1(1).text)
    endif
    end sub就这样可以了。
      

  8.   

    呵呵,简化一下:
    Sub diag()
    On Error Resume Next
    Label1.Caption = IIf(Trim(Text1 & Text2) = "" Or (Not IsNumeric(Text1 & Text2)), "", Val(Text1) * Val(Text2))
    End SubPrivate Sub Text1_Change()
    diag
    End SubPrivate Sub Text2_Change()
    diag
    End Sub
      

  9.   

    Private Sub Text1_Change()
        Label1.Caption = Val(Text1.Text) * Val(Text2.Text)
    End SubPrivate Sub Text2_Change()
        Label1.Caption = Val(Text1.Text) * Val(Text2.Text)
    End Sub
      

  10.   

    if a1<>"" and a2<>"" then
    b1=...
    label1.caption=b1
    endif