VB程序 商场打折 如果满200 打七折 如果满300 打六折 200元以下 不打折 程序编写

VB程序 商场打折 如果满200 打七折 如果满300 打六折 200元以下 不打折 程序编写,第1张

在form上面添加一个按钮、一个label标签、一个text文本框,将下面代码复制过去即可

文本框里面输入未打折之前的金额,标签上面显示打折后需要支付的金额

Private Sub Command1_Click()

dim intmount as single

intmount = text1.text

if intmount >200 or intmount = 200 then

if intmount >300 or intmount = 300 then

label1.caption = intmount * 0.6

else

label1.caption = intmount * 0.7

end if

else

label1.caption = intmount

end if

End Sub

简单的说可以这样实现:

在命令按钮中写如下代码:

do case

case thisform.text1.value>=200.00 and thisform.text1.value<400

thisform.text2.value=round(thisform.text1.value*0.95,1)

case thisform.text1.value>=400.00 and thisform.text1.value<800

thisform.text2.value=round(thisform.text1.value*0.9,1)

case thisform.text1.value>=800.00

thisform.text2.value=round(thisform.text1.value*0.8,1)

otherwise

thisform.text2.value=round(thisform.text1.value,1)

endcase

thisform.refresh

此外,要注意设置文本框的取值范围,文本框要设置成数字输入格式。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11501574.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存