我正在ASPx中进行编程,我希望能够使用在函数中提供值并在另一个函数中使用它的变量
我创建了两个函数,并尝试使用“ Return”返回,但是它不起作用
Public Function prova() As String
Dim prova2 As String = "Hola"
Return prova2
End Function
Public Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs, prova2 As String)
If prova2 = "Hola" Then
Response.Redirect("Centros.aspx")
Else
Label6.Visible = True
End If
End Sub
答案 0 :(得分:1)
将其设为Function
并返回值:
Public Function prova() As String
Dim prova As String = "Hola"
Return prova
End Function
Protected Sub Button5_Click(sender As Object, e As System.EventArgs)
If prova() = "holaa" Then
Response.Redirect("Centros.aspx")
End If
End Sub