Pergunta

I'm getting a Null Reference error with a Looped Array. I believe I need to create a new instance but can't figure out syntax.

Here is the Public declaration:

Public fbInitial() As Double
Public bmInitial() As Double
Public dpInitial() As Double

Here is the code that throws the Null error:

' Calculate initial values and write text file header
If x = 1 Then
    fbInitial(source) = FormatNumber(detPwrAvg / backMonAvg, 6)     'Sets initial SLD Front/Back ratio on first sample                    
    bmInitial(source) = FormatNumber(backMonAvg, 6)                 'Sets initial Back Monitor on first sample    
    dpInitial(source) = FormatNumber(detPwrAvg, 6)                  'Sets initial Detector Power on first sample    
    file.WriteLine("Sample;Intentionally Blank;Chamber Temp;Intentionally Blank;Back Monitor (uA);Laser Drive (mA);Intentionally Blank;Detector Power (uW);Fwd/Back Ratio;Normalized F/B Ratio;Normalized Back Monitor;Normalized Fwd Power")
End If
Foi útil?

Solução

It means that you need to specify the size of the variable array like:

Public fbInitial(1000000) As Double
Public bmInitial(1000000) As Double
Public dpInitial(1000000) As Double
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top