I am sure that this is a simple question but I am very new to vb.net and I am struggling to figure out this. basically in VBA you can use a Sub to populate an array and as long as the array has been declared public in the module this can been seen on any module.
Public reg12bound(1 To 5) As Double
Sub region12boundary()
'
' Initialize coefficients for boundary equation
'
reg12bound(1) = 348.05185628969
reg12bound(2) = -1.1671859879975
reg12bound(3) = 1.0192970039326E-03
reg12bound(4) = 572.54459862746
reg12bound(5) = 13.91883977887
'
End Sub
then this can be seen in another module using the code below
Private Function boundary23P(Temp)
Call region12boundary
boundary23P = (reg12bound(1) + reg12bound(2) * Temp + reg12bound(3) * (Temp ^ 2)) * 1000000
End Function
essentially I wish to repeat this functionality in VB.net but when I try the following
Public reg12bound(5) As Double
Sub region12boundary() ' ' Initialize coefficients for boundary equation ' ReDim reg12bound(5) reg12bound(1) = 348.05185628969 reg12bound(2) = -1.1671859879975 reg12bound(3) = 0.0010192970039326 reg12bound(4) = 572.54459862746 reg12bound(5) = 13.91883977887 ' End SubPublic Function boundary23P(ByVal Temp As Double) As Double
call region12boundary() boundary23P = (reg12bound(1) + reg12bound(2) * Temp + reg12bound(3) * (Temp ^ 2)) * 1000000 End Function
The array is populated with 0 instead of the values. The functionality seems to work fine when I populate within a function. But I would rather avoid this as most of the functions reference the same array of 34 variable which would need to be copied into each function.
Also I do realise that the reg12bound(0) value is not populated this didn't seem to be a problem in the self contained version so I am assuming this is fine from outside as well
edited to add the call to the function
0not1.