作者googookevin (我的笑点真的很低~)
看板Visual_Basic
标题[.NET] 阵列为何是空的
时间Tue May 31 14:46:15 2005
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
1F:推 BearWu:我不会用NET!!不过我用同样的方式写在VB 192.83.195.244 05/31
2F:→ BearWu:会出错咧!!不知道是不是相同的道理 192.83.195.244 05/31
3F:→ BearWu:阵列好像不行这样子宣告,里面一定要常数运算式 192.83.195.244 05/31
4F:→ BearWu:或着是数字吧!!等会VB.NET的人再解答吧 192.83.195.244 05/31