I have a usercontrol into which I want to copy data.
The data is in the form of an array of singles.
The data is loaded using a property. (get/let)
The data is stored by the usercontrol in an array of singles.
This goes for two sets of data, each has it's own source array, property and destination array.
When I copy the first array it works fine.
When I copy the second array it gives an error:
Runtime 13: type mismatch.
I tested this with a second sub that only copies teh data and only a little bit. (second commandbutton)
This gives the same error.
What is weird is that the error always comes when I copy the second array, even if I swap the lines.
I checked that everything involed uses an array of singles.
What could be the issue?
The form:
vb Code:
Private Sub c_Click()
Dim f As Long
Dim ds() As String
Dim i As Long
Dim t As Single
Dim dt() As Single
Dim dx() As Single
cd.FileName = vbNullString
cd.ShowOpen
If Dir(cd.FileName) <> vbNullString And cd.FileName <> vbNullString Then
ReDim ds(0)
f = FreeFile
Open cd.FileName For Binary As #f
ds(0) = String(LOF(f), " ")
Get #f, , ds(0)
Close #f
ds = Split(ds(0), vbCrLf)
ReDim d(UBound(ds))
For i = 0 To UBound(ds)
d(i) = ProcessData(ds(i), Len(ds(i)), False)
Next i
Erase ds
ReDim dt(UBound(d))
ReDim dx(UBound(d))
For i = 0 To UBound(d)
If i > 0 Then
If d(i).Lap_Current > d(i - 1).Lap_Current Then t = t + d(i).LapTime_Last
End If
dt(i) = t + d(i).LapTime_Current
dx(i) = d(i).BrakeTemp_LF
Next i
Erase d
'hgLF is an instance of the usercontrol
hgLF.DataX = dx
hgLF.DataY = dt '<-- runtime 13, type mismatch
hgLF.Draw
End If
End Sub
vb Code:
Private Sub Command1_Click()
Dim a() As Single
Dim b() As Single
ReDim a(1000)
ReDim b(1000)
hgLF.DataY = b
hgLF.DataX = a '<-- runtime 13, type mismatch
End Sub
The usercontrol:
vb Code:
Private varDataX() As Single
Private varDataY() As Single
Public Property Get DataX() As Single()
DataX = varDataX
End Property
Public Property Let DataX(nDataX() As Single)
varDataX = nDataX
End Property
Public Property Get DataY() As Single()
DataY = varDataY
End Property
Public Property Let DataY(nDataY() As Single)
varDataY = nDataY
End Property