复位按钮 [英] Reset button

查看:72
本文介绍了复位按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用于我的BMI \Age计算器的代码,我只想知道如何添加一个重置按钮,这样我就可以重置已放入计算器的输入,这样我就可以开始另一个计算条目。  




代码: 


Private Sub cmdCalculate_Click()

'声明变量

Dim AddAge As Long

Dim myAge As Range

Dim BMI作为范围

'设置结果范围

设置myAge = Sheet1.Range(" G8")

'用于resut的变量

设置BMI = Sheet1.Range(" H11")

'检查DOB值

如果IsDate(Me.txtDOB.Value)和我.txtDOB.Value<> 0然后

'将工作表的出生日期添加到
Sheet1.Range(" F8")= Me.txtDOB.Value

'显示公式结果在消息框中为
Me.txtAge.Value = myAge.Value

否则为
MsgBox"您需要添加正确的日期" ;
$
txtDOB.Value =" " b
退出子

结束如果

'检查重量值并增加值

如果是IsNumeric(txtWeight) )和txtWeight<> 0然后

Sheet1.Range(" G11")=格式(Me.txtWeight.Value," ### 0.0")

否则

MsgBox"你必须加一个重量"

退出Sub¥
结束如果

'显示BMI结果

Me.txtBMI = BMI

Me.txtBMI.Value =格式(BMI,&#,## 0.0")

'显示BMI分类

如果BMI< 18.5然后

MsgBox"你体重不足"
b
结束如果
b $ b b
如果BMI> = 18.5并且BMI< 25然后

MsgBox"你的体重正常"

结束如果
b $ b b
如果BMI> = 25和BMI< 30然后

MsgBox"你超重"

结束如果是b $ b b
如果BMI> 30然后

MsgBox"你是肥胖的"

结束如果

结束子



私人子cmdClose_Click()

 卸载我

 

结束子

解决方案

您好,


此论坛适用于VB.NET。我可以将您的问题转移到VBA论坛或"Excel for developers"。论坛。如果VB6或更早版本使用以下论坛。


http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier


This si the code i am using for my BMI\Age calculator, i am just wondering how i can add a reset button so i can reset the inputs already placed into the calculator so i can start another calculation entry.  

Code: 

Private Sub cmdCalculate_Click()
'Declare the variables
Dim AddAge As Long
Dim myAge As Range
Dim BMI As Range
'Set the result range
Set myAge = Sheet1.Range("G8")
'Variable for resut
Set BMI = Sheet1.Range("H11")
'Check for DOB value
If IsDate(Me.txtDOB.Value) And Me.txtDOB.Value <> 0 Then
'Add date of birth to worksheet
Sheet1.Range("F8") = Me.txtDOB.Value
'Show formula result in a message box
Me.txtAge.Value = myAge.Value
Else
MsgBox "you need to add a proper date"
txtDOB.Value = " "
Exit Sub
End If
'check for Weight value and add value
If IsNumeric(txtWeight) And txtWeight <> 0 Then
Sheet1.Range("G11") = Format(Me.txtWeight.Value, "###0.0")
Else
MsgBox "You must add a weight"
Exit Sub
End If
'Show the BMI result
Me.txtBMI = BMI
Me.txtBMI.Value = Format(BMI, "#,##0.0")
'show the BMI clasification
If BMI < 18.5 Then
MsgBox "you are underweight"
End If

If BMI >= 18.5 And BMI < 25 Then
MsgBox "You are in normal weight"
End If

If BMI >= 25 And BMI < 30 Then
MsgBox "you are Overweight"
End If

If BMI > 30 Then
MsgBox "You are Obese"
End If
End Sub

Private Sub cmdClose_Click()
 Unload Me
 
End Sub

解决方案

Hello,

This forum is for VB.NET. I can move your question to either a VBA forum or the "Excel for developers" forum. If VB6 or earlier use the following forum.

http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier


这篇关于复位按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆