双数组 [英] Double arrays
问题描述
应用程序应将二维码中存储的支付代码和费率存储在图9-59中
大批.它还应在列表框中显示来自阵列的支付代码.
btnCalc_Click过程应使用工作小时数显示工资总额
以及与所选代码相对应的支付率.适当地测试应用程序.
The application should store the pay codes and rates listed in Figure 9-59 in a twodimensional
array. It should also display the pay codes from the array in a list box. The
btnCalc_Click procedure should display the gross pay, using the number of hours worked
and the pay rate corresponding to the selected code. Test the application appropriately.
大家好,我目前在2D阵列方面遇到问题,不确定是因为我有一个列表框,还是应该将我的私有strpayrate放到我的私有子frmmain中,或者它的状态还不错,因为在这种情况下,我正在分配每个数组的值.
Hi guys im currently having issues with 2D arrays, im unsure since i have a listbox and if i should put my private strpayrate into my private sub frmmain or its simply fine the way it is, since in this case i am assigning a value to each array.
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Private strPayRate(,) As String = {{"A07", "8.50"},
{"A10", "8.75"},
{"B03", "9.25"},
{"B24", "9.90"},
{"C23", "10.50"}}
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
' fills list box with codes and then selects the first item
lstCodes.Items.Add("A07")
lstCodes.Items.Add("A10")
lstCodes.Items.Add("B03")
lstCodes.Items.Add("B24")
lstCodes.Items.Add("C23")
lstCodes.SelectedIndex = 0
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' calculates and displays the gross pay
Dim introw As Integer
Dim intcol As Integer
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub lstCodes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCodes.SelectedIndexChanged
lblGross.Text = String.Empty
End Sub
End Class
推荐答案
我目前对2D数组有疑问,我不确定是因为我有一个列表框,还是应该将我的私有strpayrate放入我的私有子frmmain或它的状态是否很好,因为在这种情况下,我正在为每个数组.
im currently having issues with 2D arrays, im unsure since i have a listbox and if i should put my private strpayrate into my private sub frmmain or its simply fine the way it is, since in this case i am assigning a value to each array.
不清楚您所说的我的私人子目录"是什么意思.因为没有名为"frmmain"的子项.如果您的意思是'frmmain_load',虽然您可能想要 在那里进行初始化.如果在子内部声明了数组,则只有在该子内部执行的代码才能访问该数组,并且由于load事件在表单加载时仅触发一次,因此似乎不太可能希望限制 该事件的数组.
It's not clear what you mean by "my private sub frmmain" because there is no sub named 'frmmain'. If you mean 'frmmain_load' then I would not expect that you would want to declare the array inside that sub, although you might want to initialise it there. If the array was declared inside the sub it would be accessible only to code executing in that sub, and since the load event only fires once when the form loads, then it seems unlikely that you would want to restrict the scope of the array to that event.
您正在复制列表框中的值条目:我希望列表框应从数组的第一列初始化.如果您在代码中的两个位置都具有相同的数据,则可以很好地表明该代码可以进行改进.
You are duplicating the entry of values in the list box: I would expect that the list box should be initialised from the first column of the array. If you have the same data in two places in your code that's a good indication that the code can be improved.
请注意不要将访问级别与范围混淆-这是两件事.
https://msdn.microsoft.com/en-us/library/76453kax.aspx
https://msdn.microsoft.com/en-us/library/1t0wsc67.aspx
Be careful not to confuse access level with scope - they are two different things.
https://msdn.microsoft.com/en-us/library/76453kax.aspx
https://msdn.microsoft.com/en-us/library/1t0wsc67.aspx
这篇关于双数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!