编写此代码的另一种方法是什么 [英] What is another way to write this code
本文介绍了编写此代码的另一种方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
' Local variable declarations
Dim dblWholesaleCost As Double ' To hold the wholesale cost
Dim dblMarkupPercentage As Double ' To hold the markup percentage
Dim dblRetailPrice As Double ' To hold the retail price
' Get the whole sale cost as input from the user.
' Verify that the value is numeric and not negative.
If Double.TryParse(txtWholesaleCost.Text, dblWholesaleCost) And
IsNumeric(dblWholesaleCost) And dblWholesaleCost > 0.0 Then
' Get the markup percentage as input from the user.
' Verify that the value is numeric and not negative.
If Double.TryParse(txtMarkupPercentage.Text, dblMarkupPercentage) And
IsNumeric(dblMarkupPercentage) And dblMarkupPercentage > 0.0 Then
' Call the CalculateRetail function and store its return value.
dblRetailPrice = CalculateRetail(dblWholesaleCost, dblMarkupPercentage)
' Display the retail cost as output to the user.
lblRetailPrice.Text = dblRetailPrice.ToString("c")
Else
' Display a message to the user indicating that the value for the markup percentage is not valid.
MessageBox.Show("The markup percentage must be a real number that is greater than zero.", "Invalid Input")
End If
Else
' Display a message to the user indicating that the value for the wholesale cost is not valid.
MessageBox.Show("The wholesale cost must be a real number that is greater than zero.", "Invalid Input")
End If
End Sub
推荐答案
查看我对你的另一个问题的解决方案:什么是编写此代码的替代方法 [ ^ ]
See my solution to your other question: What is an alternate way to write this code[^]
这篇关于编写此代码的另一种方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文