如何从函数返回变量

时间:2015-09-17 18:59:22

标签: javascript

function a (var_a) {
    // do stuff
}
function b () {
    // use the var_a to call function
    a(var_a);
}

如果var_a通过调用function a()运行function b(),我如何退回var_a

要知道的是function a() Option Compare Database Sub test() Dim bolValid As Boolean Dim rng As Excel.Range Dim rngFound As Excel.Range Dim strHeader() As Variant ' ... Dim wb As Excel.Workbook, ws As Excel.Worksheet Set wb = Excel.Workbooks.Open("M:\My Documents\Heat Trace\Macro Workbooks\StackOverflow\test1.xlsx") wb.Application.Visible = True Set ws = wb.Sheets("Sheet1") Set rng = Range("A1:A1") strHeader() = Array("this", "again") For i = 0 To UBound(strHeader) Set rngFound = rng.Find( _ What:=strHeader(i), _ After:=rng(rng.Rows.Count, rng.Columns.Count), _ LookAt:=xlWhole, _ MatchCase:=True _ ) If rngFound Is Nothing Then bolValid = False Exit For ElseIf i = UBound(strHeader) Then bolValid = True End If Next i Set rng = Nothing Set ws = Nothing wb.Close Set wb = Nothing End Sub 运行期间被修改。

1 个答案:

答案 0 :(得分:1)

现在您需要下一级var

var var_d = "Hello World!";

function C (var_c) {

    function a (var_a) {
        // do stuff with var_a
    }
    function b () {
        // use the var_c to call function a
        a(var_c);
    }

    return b();
}

function D () {
    C (var_d);
}