从函数返回一个结果数组

时间:2015-02-19 11:37:09

标签: vb.net function return

Private Function lang_array(ByVal temp As Double) As Double
    'This program call the subroutine langmuir to calculate langmuir constants
    'of each molecule for the small cage and for the large cage
    Dim molenum As Integer = 1 ' Number of molecular species
    Dim sigma(10) As Double  ' value of sigma for each species
    sigma(0) = 0.00000000030197
    Dim radius(10) As Double  ' value of core radius for each species
    radius(0) = 0.000000000072
    Dim edep_div_k(10) As Double  ' value of energy depth/k for each species
    edep_div_k(0) = 171.3
    Dim z_small As Double = 20 ' coordination number for small cage 
    Dim z_large As Double = 24 'coordination number for large cage 
    Dim r_small As Double = 0.000000000391 ' radius of small cage
    Dim r_large As Double = 0.000000000433 ' radius of large cage
    Dim n_small As Double = 1.0 / 23.0 'number of small cage per one water molecule 
    Dim n_large As Double = 3.0 / 23.0 'number of large cage per one water molecule     
    'In langmuir constant array c[k][i], suffix k changes with molecular species
    ' and suffix i changes with cavity type
    'In suffix i, 0 indicates small cavity and 1 indicates large cavity.
    Dim c1, c2, c3, c4, c5 As Double
    Dim c(2, 2) As Double
    Dim k As Integer
    For k = 0 To molenum
        c1 = z_small
        c2 = r_small
        c3 = sigma(k)
        c4 = radius(k)
        c5 = edep_div_k(k)
        c(k, 0) = langmuir(temp, c1, c2, c3, c4, c5)
    Next
    ' Calculate langmuir constant for large cavity
    For k = 0 To molenum
        c1 = z_large
        c2 = r_large
        c3 = sigma(k)
        c4 = radius(k)
        c5 = edep_div_k(k)
        c(k, 1) = langmuir(temp, c1, c2, c3, c4, c5)
    Next
    **Return (c)**
End Function

'我试图返回数组的值(c(k,0)& c(k,1)),但我无法做到。你能帮忙吗

1 个答案:

答案 0 :(得分:0)

将签名更改为:

 Private Function lang_array(ByVal temp As Double) As Double(,)

应该工作