Bob,
There are a few optimizations you can make on your code.
(1) I'm not sure how sophisticated the VB6 compiler is, but modern compilers will usually recognize when something evaluates to a constant. If you are performing an operation such as Log(10) over and over in a loop, this will always evaluate to the same value. So there is no need to recalculate this value in every iteration of the loop. Instead create some constants and pull those values out of the loop.
'Perform this calculation once before the loop
Const c1 as Double = 2 ^ 15
'With some simple algebra you can simply the 20 * (...) / Log(10) into 20 / Log(10) as one constant. Unfortunately
'VB6 does not consider Log(10) as a constant expression but you can either assign 20 * Log(10) to a non constant
'variable or you can simply take Log(10) out of the equation since it evaluates to 1 anyway.
Const c2 as Double = 20 '* Log(10) = 1
(2) There is a CWArray.AbsArray function that will return the Absolute Value of every item in an Array. This may be slightly quicker than performing this inside the loop.
Wav = CWArray1.AbsArray(Wav)
(3) There is also a CWArray.SearchArray function that will return an Array that contains only values of a certain range. So, after getting the absolute value of the array, you could then use SearchArray based on bounds such as (0.0000001, 1000000 or Number Larger than any value in your Array). This will remove all values of zero automatically. Unfortunately, this function returns a two dimensional array, even if you perform it on a one dimensional array. So it actually may be more efficient to use your current method of checking each value.
(4) You are performing the Cnt + 1 operation twice. To perform the operation only once, increment Cnt before you adjust Wav1(Cnt +1)
Cnt = Cnt + 1
Wav1(Cnt) = N + 16.05015
You should knock quite a few instructions out of your algorithm with these changes.
Let me know if you have further questions.
Thanks,
Tyler Tigue