繁体   English   中英

如何在两个过程之间传递变量数据

[英]How to pass variable data between two procedures

我试图将变量信息从一个过程传递到另一个过程,.net方面我经验不足,我无法找到更多有关执行此操作的信息。

    Sub ValidationScript()
    Dim checkVar As Boolean
    'First consistency check \\ Length based check
    If emailP.InnerText.Length > 3 Then
        If passwordP.InnerText.Length > 5 Then
            checkVar = True
        Else
            Con1.InnerText = "You have entered an Incorrect Email or password."
            checkVar = False
        End If
    Else
        Con1.InnerText = "You have entered an Incorrect Email or password."
        checkVar = False
    End If
End Sub


Sub loginBtn1_Click(checkVar As Boolean) Handles loginBtn1.ServerClick
 if checkVar = true then
     Response.Redirect("Home.aspx")
end sub

我正在尝试从checkVar获取信息,以便第二个子loginBtn1可以访问该信息。

目前尚不清楚如何在代码中调用ValidationScript,但是现在我认为您只需将Sub ValidationScript更改为一个返回布尔值的Function ValidationScript

Function ValidationScript() As Boolean

    Dim checkVar As Boolean = False

    'First consistency check \\ Length based check
    If emailP.InnerText.Length > 3 Then
        If passwordP.InnerText.Length > 5 Then
            checkVar = True
        Else
            Con1.InnerText = "You have entered an Incorrect Email or password."
        End If
    Else
        Con1.InnerText = "You have entered an Incorrect Email or password."
    End If
    return checkVar
End Function

然后在Click事件中调用它(但请与正确的参数一起使用)

Sub loginBtn1_Click(ByVal Sender as Object, ByVal e As EventArgs ) Handles loginBtn1.ServerClick
    if ValidationScript() = true then
        Response.Redirect("Home.aspx")
    else
        .....
    End If
end sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM