Hi guys, ive got a friend who is writing a program in VB for a geophysical application. Im a FORTRAN90 and IDL boy myself, so i dont know what the problem is. If anyone can give some help on this it would be greatly appreciated. Thanks. Here it is:
i am writing an auto-correlation program for short dicrete signals.
i am having a problem where i am getting an error saying the subscript is out of range. my code is below with the problem line starting:
sngAns(intLoop) = sngAns(intLoop) + sngAlldata(intCount) * sngAlldata(intCount - intLoop)
any help or suggestion will be greatly appreciated
thanks
i am writing an auto-correlation program for short dicrete signals.
i am having a problem where i am getting an error saying the subscript is out of range. my code is below with the problem line starting:
sngAns(intLoop) = sngAns(intLoop) + sngAlldata(intCount) * sngAlldata(intCount - intLoop)
Code:
Private sngAlldata(1 To 100) As Single, intSamples As Integer Private Sub butload_Click() 'declare some varibales Dim sngdata As Single, strtest As String Dim intFree As Integer 'set some variables intFree = FreeFile 'set a dialog box allowing the user to search for his/her data CommonDialog1.ShowOpen strtest = CommonDialog1.FileName 'read in a file of data Open strtest For Input As #intFree intSamples = 1 'print some headings ' set up a loop that runs till the end of file Do While Not EOF(intFree) Input #intFree, sngdata sngAlldata(intSamples) = sngdata Text1.SelText = Str(sngdata) & vbCrLf intSamples = intSamples + 1 Loop intSamples = intSamples - 1 Text1.SelText = "no of samples = " & Str(intSamples) & vbCrLf End Sub Private Sub butproautocor_click() Dim intCount As Integer, intLoop As Integer, sngAns(1 To 199) As Single, intCount1 As Integer, intN As Integer, intM As Integer For intCount1 = 1 To 199 sngAns(intCount1) = 0 Next intCount1 intN = intSamples intM = intSamples 'no samples of a and b is n and m respectively 'set loopcounter for tau values to increment difference between them For intLoop = -(intM - 1) To intN - 1 'to increment staring values to multiply For intCount = 1 To intN 'to multiply then add them up sngAns(intLoop) = sngAns(intLoop) + sngAlldata(intCount) * sngAlldata(intCount - intLoop) Next intCount Text1.SelText = Str(sngAns(intLoop)) & vbTab & Str(intLoop) & vbCrLf Next intLoop End Sub
thanks
Comment