[.NET] 陣列為何是空的
Dim no As Integer = 0
Dim num As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label5.Visible = False
num = Val(InputBox("請輸入學生數目", ""))
Label1.Text = "請輸入" & num & "筆學生姓名和成績!"
Label2.Text = "第" & no + 1 & "筆"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s_score(num - 1) As Single
Dim s_name(num - 1) As String
Dim i As Integer
Dim tt As String
Dim ss As String
s_name(no) = TextBox1.Text
s_score(no) = TextBox2.Text
no += 1
Label2.Text = "第" & no + 1 & "筆"
Label5.Text = "編號 姓名 分數" + vbNewLine
TextBox1.Text = ""
TextBox2.Text = ""
If no = num Then
Label5.Visible = True
For i = 0 To num - 1 Step 1
Label5.Text &= i & " " & s_name(i) & " " & "
" & s_score(i) & vbNewLine
Next i
End If
End Sub
這程式是希望最後能列出所有資料~但為何最後都只能顯示出最後一筆輸入的資料
呢?其他前面輸入的資料都會成為0~好奇怪喔!
是不是存取陣列出了問題阿?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.239.213
推
192.83.195.244 05/31, , 1F
192.83.195.244 05/31, 1F
→
192.83.195.244 05/31, , 2F
192.83.195.244 05/31, 2F
→
192.83.195.244 05/31, , 3F
192.83.195.244 05/31, 3F
→
192.83.195.244 05/31, , 4F
192.83.195.244 05/31, 4F
討論串 (同標題文章)
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章