Evaluare utilizator: 0 / 5

Steluță inactivăSteluță inactivăSteluță inactivăSteluță inactivăSteluță inactivă
 

In this video tutorial you will learn about class level constants. Class-level constants are accessible to all procedures in a class. Local constants have local scope, meaning that each is declared and uses inside a procedure. Local constants are not visible to statements outside the procedure in which they are declared.

{jcomments on}

A class-level constant is declared inside a class declaration, but not inside any procedure. Class-level constants have class scope because they are visible to all statements inside the class.

Code:

PublicClassForm1

  

Const dbl_PI AsDouble = 3.14159

 

   PrivateSub btnCalculate_Click(sender AsObject, e AsEventArgs) Handles btnCalculate.Click

       Dim intRadius AsInteger

       Dim dblAreaCircle AsDouble

      

           intRadius = CInt(txtRadius.Text)

           dblAreaCircle = intRadius ^ 2 * dbl_PI

           lblResult.Text = dblAreaCircle.ToString("n2")  

          

      

   EndSub

   PrivateSub btnNext_Click(sender AsObject, e AsEventArgs) Handles btnNext.Click

       txtRadius.Clear()

       lblResult.Text = String.Empty

       txtRadius.Focus()

   EndSub

   PrivateSub btnExit_Click(sender AsObject, e AsEventArgs) Handles btnExit.Click

       Me.Close()

   EndSub

EndClass