Results 1 to 3 of 3

Thread: loop through the structure values

  1. #1

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    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"
    Last edited by karthikeyan; Mar 5th, 2008 at 02:19 AM. Reason: to correct the code tag
    Loving dotnet

  2. #2
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: loop through the structure values

    What is the error message you get?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: loop through the structure values

    This:
    vb.net Code:
    1. 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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width