VB编程问题,会者请进

来源:百度知道 编辑:UC知道 时间:2024/07/07 18:55:21
本人最近刚学VB,水平很菜,请高手告知如何编程附图的程序。有两个OptionButton,选左边那个(乘),按下Cmd使z框=x乘y;选右边那个(除),使z=x除y。请高手指导,有代码最好。嘿嘿,小弟的分不多哦,大家别嫌弃

private sub command1_click()
if option1.value=true then
text3.text=text1.text*text2.text
elseif option2.value=true and text1.text<>0 then
text3.text=text1.text/text2.text
elseif option2.value=true and text1.text=0 then
msgbox"除数不能为0"
text1.text=""
text2.text=""
text3.text=""
end if
end sub
在VB里试了下 可行

If Option1.Value = True Then
Text3 = Val(Text1) * Val(Text2)
End If
If Option2.Value = True Then
If val(Text2) <> 0 Then
Text3 = Val(Text1) / Val(Text2)
End If
End If

dim mi as integer
private sub option1_click()
mi=1
end sub
private sub option2_click()
mi=-1
end sub
private sub form_load()
mi=1
end sub
private sub command1_click()
if mi<>-1 then text3.text=val(text1.text)*(val(text2.text))^mi
if mi=-1 then
if val(text2.text)<>0 then text3.text=val(tex