Pass parameters to subroutine (VB.net) : subroutine « Language Basics « ASP.NET Tutorial






<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="output" runat="server"></asp:Label>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>

File: Default.aspx.vb

Partial Class Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        output.Text = String.Empty

        DisplayMessage("Welcome to my website<br />")
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        DisplayMessage("Welcome to my website<br />")
    End Sub

    Private Sub DisplayMessage(ByVal message As String)
        Dim i As Integer
        For i = 1 To 4
            output.Text &= message
        Next i
    End Sub

End Class








2.6.subroutine
2.6.1.Define and call sub module (function) in asp.net page (VB)
2.6.2.asp:Button action event calls a subroutine
2.6.3.Pass parameters to subroutine (VB.net)