পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, April 5, 2017

VBScript - Constants

Constant is a named memory location used to hold a value that CANNOT be changed during the script execution. If a user tries to change a Constant Value, the Script execution ends up with an error. Constants are declared the same way the variables are declared.

Declaring Constants

Syntax:

[Public | Private] Const Constant_Name = Value
The Constant can be of type Public or Private. The Use of Public or Private is Optional. The Public constants are available for all the scripts and procedures while the Private Constants are available within the procedure or Class. One can assign any value such as number, String or Date to the declared Constant.

Example 1:

In this example, the value of pi is 3.4 and it displays the area of the circle in a message box.
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

  Dim intRadius
  intRadius = 20
  const pi=3.14
  Area = pi*intRadius*intRadius
  Msgbox Area

</script>
</body>
</html>

Example 2:

The below example illustrates how to assign a String and Date Value to a Constant.
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

  Const myString = "VBScript"
  Const myDate = #01/01/2050#
  Msgbox myString
  Msgbox myDate

</script>
</body>
</html>

Example 3:

In the below example, the user tries to change the Constant Value; hence, it will end up with an Execution Error.
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

   Dim intRadius
   intRadius = 20
   const pi=3.14
   pi = pi*pi 'pi VALUE CANNOT BE CHANGED.THROWS ERROR'
   Area = pi*intRadius*intRadius
   Msgbox Area
   
</script>
</body>
</html>

No comments:

Post a Comment