loop through the structure values
hi, here is my class:
Code:
Partial Public Class MainForm
'FFT core Dat
Public Structure FFTcoreTypeA
<VBFixedArrayAttribute(899)> Public fft125() As Single 'FFT Data 1.25Hz pitch
<VBFixedArrayAttribute(21)> Public fftoct3() As Single 'FFT 1/3oct Data
Public fft_all As Single 'FFT 全域値
Public fft_high As Single 'FFT 高域値
End Structure
'FFT scan Dat
Public Structure FFTscanTypeA
Public fft_dat As FFTcoreTypeA
Public use_rate As Single 'use rate 1.0 or 0.0
End Structure
'FFT hour Dat
Public Structure FFThourTypeA
Public fft_mean As FFTcoreTypeA
Public fft_max As FFTcoreTypeA
Public fft_min As FFTcoreTypeA
Public use_rate As Single 'use rate 0.0 to 1.0
End Structure
Public VELscanA As FFTscanTypeA
Public ACCscanA As FFTscanTypeA
Public VELhourA As FFThourTypeA
Public ACChourA As FFThourTypeA
Sub ACC(ByVal strDatFile As String)
Dim length As Integer
length = Len(VELscanA)
FileOpen(1, strDatFile, OpenMode.Random, , , length)
FileGet(1, VELscanA, 1)
FileClose(1)
End Sub
Sub VEL(ByVal strDatFile As String)
Dim length As Integer
length = Len(VELhourA)
FileOpen(2, strDatFile, OpenMode.Random, , , length)
FileGet(2, VELhourA, 1)
FileClose(2)
End Sub
End Class
so now i need call the "VEL" method and to loop through the "VELhourA" values .
here i have tried like as as follows:
Code:
Dim struFFThourTypeA(0) As MainForm.FFThourTypeA
struFFThourTypeA(0) = clsMainForm.VELhourA
For Each fft_mean As MainForm.FFTcoreTypeA In struFFThourTypeA(0)
Next
so i am getting compilation error. so please help me to loop through the values in "VELhourA"
Re: loop through the structure values
What is the error message you get?
Re: loop through the structure values
This:
vb.net Code:
Dim struFFThourTypeA(0) As MainForm.FFThourTypeA
is declaring an array variable named struFFThourTypeA with one element. Note, the name of the array is struFFThourTypeA, NOT struFFThourTypeA(0). With that said, what do you think is wrong with this:
Code:
For Each fft_mean As MainForm.FFTcoreTypeA In struFFThourTypeA(0)
The highlighted part specifically refers to the first element of the array, NOT the array itself. If you want to loop through the entire array then you have to specify the array, not one element of the array.
That said, what's the point of looping through an array that you've specifically stated has only one element? Is that just an example?