Page level variable and function level variable (VB.net) : Variable Scope « Language Basics « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Language Basics » Variable Scope 
Page level variable and function level variable (VB.net)

<script language="vb" runat="server"
    Dim Global As String ="<br><u>Hello I'm a persistent global variable</u>"   

Sub Page_Load()  

    Response.Write (Global)     
    Response.Write ("<BR />Calling Subroutine 1...")
    Call Subroutine_1()
    Response.Write ("<BR />Calling Subroutine 2...")
    Call Subroutine_2()
    Response.Write ("<BR />Calling Subroutine 1...")
    Call Subroutine_1()
End Sub

  Sub Subroutine_1()
    Dim Different As String
    Different = "<i>Hello I'm the variable Different in Subroutine 1</i>"
    Response.Write (Different)
    Response.Write (Global)
  End Sub

  Sub Subroutine_2()
    Dim Different As String
    Different = "<b>Hello I'm the variable Different in Subroutine 2</b>"
    Response.Write (Different)
    Response.Write (Global)
  End Sub
</script>
<html>
<head>
<title>Scope</title>
</head>
<body>
</body>
</html>

           
       
Related examples in the same category
1.Local variable inside a function (VB.net)
2.Define page level variables (VB.net)
3.Function Level variables (C#)
4.Page Level Variable (C#)
5.block-level variables (C#)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.