所以基本上我试图解决这个问题:
我遇到了一些问题。首先,我希望能够进入这一年并让一切正常运转,但我不确定如何做到这一点。我还需要能够计算每年的总数,然后计算所有年份的总数。
我对数组很新,任何帮助都会非常感激。
Public Class Form1
'Set values for the quaters
Dim quater() As Integer = {1, 2, 3, 4}
Dim salesbox(3, 11) As Decimal
Dim total() As Decimal = {0}
Dim Yearss() As Integer = {1999, 2000, 2001, 2002}
'Simple sub to show the headings on the list box
Sub showtitles()
Dim message As String
OutBox.Items.Clear()
message = "Year" & ControlChars.Tab &
"Q1" & ControlChars.Tab &
"Q2" & ControlChars.Tab &
"Q3" & ControlChars.Tab &
"Q4" & ControlChars.Tab &
"Total" & ControlChars.Tab
OutBox.Items.Add(message)
End Sub
'Input for that quater/sales for that quater/year
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim getQ As Integer
Dim getsales As Decimal
Dim message As String
Dim getyear As String
message = "Enter Quater"
getQ = InputBox(message) - 1
message = "Enter sales for Quater"
getsales = InputBox(message)
message = "Enter year"
getyear = InputBox(message) - 1
salesbox(getyear, getQ) += getsales
End Sub
好的,对于这部分,我可以让数字进入正确的位置,但仅限于1-4年的这些默认值。
由于某种原因,我无法弄清楚如何输入年份,并在输出框中将其提升到年份
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Message As String
Dim row As Integer
Dim column As Integer
Call showtitles()
For row = 0 To 3 Step 1
Message = quater(row) & ControlChars.Tab
For column = 0 To 6 Step 1
Message += FormatCurrency(salesbox(row, column)) & ControlChars.Tab
Next
OutBox.Items.Add(Message)
Next
For column = 0 To 1 Step 1
Message = Yearss(column)
Next
End Sub