基本上,我被要求在三年的第一季度向用户提供与日照总量有关的价值。
我的主表单上有一个按钮,上面写着“开始”。
单击此按钮时,我希望打开一个提示框。此提示符框应提示用户输入9个值,这些值将在三年内分割。E.g
"Please enter the total sunshine for January 2011"
"Please enter the total sunshine for February 2011"
"Please enter the total sunshine for March 2011"
"Please enter the total sunshine for January 2012"
"Please enter the total sunshine for February 2012"
"Please enter the total sunshine for March 2012"
"Please enter the total sunshine for January 2013"
"Please enter the total sunshine for February 2013"
"Please enter the total sunshine for March 2013"我需要将值存储在单独的数组中。因此,与三年中的每一年相对应的输入值应该包含在它们自己的数组中。
发布于 2014-04-12 14:47:45
下面的代码将为您所需的内容提供解决方案。由于我不知道输入这些值后将如何处理这些值,我建议您:(a)将它们保存到表或其他地方;(b)添加处理非数字值的代码(即重试)。如果我是一名用户,每次运行例程时都要回答9个问题,我就不会很高兴……
Sub Get_Sunshine_Values()
Dim a2011(3) As Double
Dim a2012(3) As Double
Dim a2013(3) As Double
a2011(1) = InputBox("Please enter the total sunshine for January 2011", "Sunshine")
a2011(2) = InputBox("Please enter the total sunshine for February 2011", "Sunshine")
a2011(3) = InputBox("Please enter the total sunshine for March 2011", "Sunshine")
a2012(1) = InputBox("Please enter the total sunshine for January 2012", "Sunshine")
' repeat for Feb & Mar.
a2013(1) = InputBox("Please enter the total sunshine for January 2013", "Sunshine")
' repeat for Feb & Mar.
End Subhttps://stackoverflow.com/questions/23030851
复制相似问题