[VB2008] 如何正確呼叫,寫在類別庫的陣列
想請問大家一個問題
我在類別庫中寫了一個陣列,類別庫的namespace為studyhost,程式碼如下:
Public Class math
Private _buffername as String
Private _idx as integer
Private _xaxis() As Single
Private _yaxis() As Single
Private _fname() as string
Property buffername() As String
Get
Return _buffername
End Get
Set(ByVal value As String)
value = _buffername
End Set
End Property
Property fname() As String()
Get
Return _fname
End Get
Set(ByVal value() As String)
value = _fname
End Set
End Property
Property idx() As Integer
Get
Return _idx
End Get
Set(ByVal value As Integer)
If IsNumeric(value) = False Then
Exit Property
End If
value = _idx
End Set
End Property
Property xaxis() As Single()
Get
Return _xaxis
End Get
Set(ByVal value As Single())
value = _xaxis
End Set
End Property
Property yaxis() As Single()
Get
Return _yaxis
End Get
Set(ByVal value As Single())
value = _yaxis
End Set
End Property
而主程式如下
Public Class Form1
Dim buffer As String = ""
Dim mytool As New studyhost.math
Sub open()
mytool.idx = 0
Me.OpenFileDialog1.Filter = "文字檔(*.txt)|*.txt"
If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each record As String In Me.OpenFileDialog1.FileNames
mytool.fname(mytool.idx) = record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^在這邊出現"使用new關鍵字建立
物件值型個體"
mytool.idx = mytool.idx + 1
mytool.buffername = mytool.buffername +_
mytool.fname(mytool.idx) & vbNewLine
Next
Me.TextBox1.Text = mytool.buffername
End If
曾經也試過加入redim 語法去修正這個錯誤,不過還是無法正確的解決問題,希望大家
可以提醒一下,要怎樣去修正,謝謝!!
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.43.86
推
08/02 14:36, , 1F
08/02 14:36, 1F
推
08/02 14:36, , 2F
08/02 14:36, 2F
→
08/02 14:36, , 3F
08/02 14:36, 3F
※ 編輯: jonsen 來自: 140.114.43.86 (08/02 14:38)
→
08/02 14:41, , 4F
08/02 14:41, 4F
→
08/02 14:41, , 5F
08/02 14:41, 5F
※ 編輯: jonsen 來自: 140.114.43.86 (08/02 14:44)
→
08/02 14:49, , 6F
08/02 14:49, 6F
→
08/02 14:50, , 7F
08/02 14:50, 7F
→
08/02 14:55, , 8F
08/02 14:55, 8F
→
08/02 14:56, , 9F
08/02 14:56, 9F
→
08/02 17:14, , 10F
08/02 17:14, 10F