pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

Understanding the Basics of Visual Basic Script

Visual Basic Script, derived from the programming language “Visual Basic”.
Excerpt from the article “Playing with VBScript: TBS Gladiators”:

Visual Basic Script (…) comes bundled with Windows operating systems -since about 1996-, and is part of Microsoft’s Visual Basic engine -year 1991 to 2008-.
Visual Basic was continued in the “dot net” (.NET) platform, being called “Visual Basic .NET” after Visual Basic reached its version 6 and was discontinued.
The Visual Basic Script code can be written without using additional programs, and as an interesting fact, the notepad can be used for this task.

Preliminary concepts.

VARIABLES.

They are elements that store information, either numerical values, or specific amounts of text.

We can store these data in a variable, to have them available throughout the program we are creating.

This is the case of games in which the characters lose money (variable to which cash amounts will be subtracted), or health when receiving physical damage (lives are subtracted or vitality is taken away), or gain points for playing well or performing specific tasks (points are added to the general score of that player).
All you have to do, is make up a word (or choose a letter) and tell Visual Basic Script that that word or letter is “worth something”. For example:

SUM = 20
a = c + b
Name = “Marcos”.
p = “hehehe”

Anyone who has used the “MEMORY” function on a pocket calculator will already be aware of how a variable works, having seen these simple examples.

In all cases, the variable is placed first, then the equals sign, then the value or text. If you are dealing with numbers or mathematical operations, these are written in the typical way, but if you are dealing with text, don’t forget to write it in quotation marks.

What not to do:

Do not use words with tilde or eñe… unfortunately, the Spanish language, has not been taken into account by the vbscript programmers.
Do not use spaces or symbols (except for the underscore “_” and the minus sign “-“, which are allowed).
Do not write words that are too long.

The following cases will lead to errors. Can you tell why?

a) Region = “Soriano”.
b) Departure time = 15:00:00
c) NumberOfStoriesInTheBrickBuildingOfTheConstructionCompanyInPandoCity = 6
d) Age = 25
e) Name = Mariana
f) Value = “38911
g) $uruguayos = 4000

Inputbox function

It is used to “ask a question” to the user, and “store its answer” in a variable.
Its “short form” is the following:

Inputbox (“”)

This has several problems and drawbacks:

The user’s answer will not be saved anywhere, even though the Inputbox will be displayed and perform part of its function.
Between the quotation marks, there should be a message that gives the user an idea of what is wanted. Otherwise, what question is it going to answer, when none has been asked?
You are not taking full advantage of the Inputbox’s capabilities.

To store the answer in a variable, you need to type the variable name, followed by an equals sign, and then develop the Inputbox function:

Question = Inputbox (“”)

Now that we know all this, it will be better to use its “almost complete form”, which consists of 3 parts:
Question – Title – “Default” answer (in that order).

Question = Inputbox (“Have you ever seen such a complete Inputbox?”, “Demonstration of the Inputbox command”, “Default answer”).

Why have we explained the “almost complete” version and not the “complete” version?
For several reasons.
Inputbox can also be told where on the screen to be positioned, which is totally inapplicable to other text display commands that are permanently used in vbscript, and also because Microsoft has not fully adapted the Inputbox function on operating systems after Windows XP, believe it or not. The Inputbox function was never well thought out or well constructed, therefore, we will only take advantage of what is really useful and discard what is wrong.

Solutions of the errors in the section “Variables”:
(a) The name of the variable, is written with tilde. Solution: rename it as “Region”.
b) The variable name contains spaces. Solution: rename it as Horse_is_real or Horseisreal.
c) The variable name is too long. It should be possible to replace it with a name of up to 15 characters, approximately (this is recommended).
d) The variable name contains the letter “ene” if you are coding in a language like Spanish. The tildes and the n are not considered in several programming languages. It is a pity, but it is the reality. Solution: rename the variable “Años” to “Anyos”, “Anios”, or something similar.
e) The text to be stored in the variable “Name” is not written between quotation marks, and will be taken as a numeric value. Remember: the text is “enclosed in quotation marks”; the numerical values are not.
f) Reverse case of case “e”. The number to be stored in the variable “Value” is being treated as text, because it has been written between quotation marks. 38911, will be taken as text, not as a number.
g) Case similar to cases “a” and “d”: the variable name contains unsuitable characters. Solution: we could replace the variable name.

Filed Under: Articles

Latest Articles

How To Install Drivers For Your Creative Sound Card

Its necessary to install device drivers and applications to use the Sound Blaster Audigy. The following instructions - applicable to all supported Windows operating systems - describe how to install these drivers and associated bundled applications: After installation of the Sound Blaster … [Read More...]

Top 4 Free Online Design Tools that Use Machine Learning

A few months ago, we told you about a series of free online image editing tools. In practice, these are simple alternatives to Adobe Photoshop that are often used for common actions such as cropping an image, placing a frame or adding brightness to a photograph. However, all these tools, including … [Read More...]

Installing the Software for the ADVC-55 DV Converter – including NERO

Now it's time to install the Canopus Let's CONVERT application. Please note: Since the creation of this tutorial the Canopus Let's CONVERT software has been taken off release. Load the Installation CD-ROM. Provided the ADVC-55 device is plugged into the PC ... ... we'll be … [Read More...]

Revolutionize Your Internet Experience with Orbi 960 – The Ultimate WiFi System

In a world where seamless connectivity is essential, slow and unreliable internet connections are a major problem. Whether you are running a business, … [Read More...]

Do You Need a VPN When Trading Cryptocurrency?

There’s no doubt that the biggest global industries in 2023 are tech-driven, while there remains a significant crossover between many of these … [Read More...]

Goodbye Bitcoin: the 3 alternative cryptocurrencies that have great upside potential, according to experts

Bitcoin has been a very lucrative investment for people that got into it early. One report from The Motley Fool pointed out that $10 of bitcoin … [Read More...]

Self-driving cars face their Achilles’ heel and may be targets of hackers

The market for self-driving cars is booming. Customers spent $22.22 billion on these autonomous vehicles in 2021 and they will likely spend more in … [Read More...]

How to avoid scams with bitcoin and other cryptocurrencies

Cryptocurrencies got a bad reputation when scams multiplied like ants on a piece of cake. Even today many people associate bitcoin and other … [Read More...]

WHAT IS CLOUD COMPUTING AND WHAT ARE ITS MAIN BENEFITS?

Users are Increasingly using cloud computing to store their information, which is replacing local storage. The business digitization process goes … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Synology America DiskStation 2-Bay Network Attached Storage

  Many companies and individuals are looking for an efficient way to share files on a network. They may lack the technical skills to implement … [Read More...]

How Do Computers Make Pictures?

Sure computer graphics have come a long way, but the question is: how?? Or, what's a pixel? What's a bitmap (or a raster)? How, in fact, does a … [Read More...]

A Cool Computer– Case Closed and Location, Location, Location

We have been writing a series of articles on how to keep your PC running cool and efficiently. Keeping a computer running cool is important because … [Read More...]

[footer_backtotop]

Copyright © 2023 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors