Visual Basic Programming Basics
Visual Basic Programming Basics
2. Build Application how to code with visual basic basic programming visual programming
3.Controls
4. Write Code
5. VB Data
5.1 Visual Basic Data Types
6. Variables We come across all kinds of data in our daily life. For example, we need to handle data such as names, addresses, money, date, stock
quotes, statistics and more every day. Similarly, in Visual Basic, we have to deal with all sorts of data, some can be mathematically
7. If and IIf( ) calculated while some are in the form text or other forms. VB divides data into different types so that they are easier to manage when we
need to write the code involving those data. VB6 classifies the information mentioned above into two major data types, they are the numeric
VB6 Made Easy Book
data types and the non-numeric data types.
Numeric data types are types of data that consist of numbers that can be computed mathematically with standard operators. Examples of numeric data
types are height, weight, share values, the price of goods, monthly bills, fees and others. In Visual Basic, numeric data are divided into 7 types, depending
on the range of values they can store.
Learn More
8. Select Case
Calculations that only involve round figures can use Integer or Long integer in the computation. Programs that require high precision calculation need to
9. Looping use Single and Double decision data types, they are also called floating point numbers. For currency calculation , you can use the currency data types.
10. Functions Intro Lastly, if even more precision is required to perform calculations that involve many decimal points, we can use the decimal data types. These data types
summarized in Table 5.1
11. Math Functions
Table 5.1 Numeric Data Types
12. Format Function
Type Storage Range of Values
13. String Functions
Byte 1 byte 0 to 255
14. Sub Procedure Integer 2 bytes -32,768 to 32,767
15. Excel VBA Functions Long 4 bytes -2,147,483,648 to 2,147,483,648
16. Arrays -3.402823E+38 to -1.401298E-45 for negative values 1.401298E-45 to 3.402823E+38 for
Single 4 bytes
positive values.
17. Create Files
-1.79769313486232e+308 to -4.94065645841247E-324 for negative values
18. Create Graphics Double 8 bytes
4.94065645841247E-324 to 1.79769313486232e+308 for positive values.
19. Create DVD Player
Currency 8 bytes -922,337,203,685,477.5808 to 922,337,203,685,477.5807
20. Create Audio Player
+/- 79,228,162,514,264,337,593,543,950,335 if no decimal is use +/-
Decimal 12 bytes
21. Create Picture Viewer 7.9228162514264337593543950335 (28 decimal places).
24. Advanced Database Nonnumeric data types are data that cannot be manipulated mathematically. Non-numeric data comprises string data types, date data types, boolean data
types that store only two values (true or false), object data type and Variant data type .They are summarized in Table 5.2
25. ADO Control
Table 5.2: Nonnumeric Data Types
26. DataGrid Control
30. Animation 1
String(variable length) Length + 10 bytes 0 to 2 billion characters
31. Animation 2
32. Animation 3
Date 8 bytes January 1, 100 to December 31, 9999
33. Web Browser
39. Printing
Variant(text) Length+22 bytes Same as variable-length string
40. Creating Report
& Long
! Single
# Double
VB6 Home
@ Currency
1. Introduction
2. Build Application In addition, we need to enclose string literals within two quotations and date and time literals within two # sign. Strings can contain any characters,
including numbers. The following are few examples:
3.Controls
memberName="Turban, John."
4. Write Code TelNumber="1800-900-888-777"
5. VB Data LastDay=#31-Dec-00#
ExpTime=#12:00 am#
6. Variables
VB6 Made Easy Book Ad Mission critical data center full of quali ed specialists with advanced
knowledge&skills.
Ad
AT TOKYO Corporation
Learn More
27. SQL Queries If you want to declare more variables, you can declare them in separate lines or you may also combine more in one line , separating each variable with a
comma, as follows:
28. More SQL Querrries
Dim VariableName1 As DataType1, VariableName2 As DataType2,VariableName3 As DataType3
29. E-library
36. Complie/Distribute Unlike other programming languages, Visual Basic actually doesn't require you to specifically declare a variable before it's used. If a variable isn't declared,
VB willautomatically declare the variable as a Variant. A variant is data type that can hold any type of data.
37. Creating Menu
38. Keyboard Handling For string declaration, there are two possible types, one for the variable-length string and another for the fixed-length string. For the variable-length string,
just use the same format as example 5.1 above. However, for the fixed-length string, you have to use the syntax as shown below:
39. Printing
Dim VariableName as String * n
40. Creating Report
where n defines the number of characters the string can hold.
VB6 Made Easy Paperback
For example,
VB2019 VB2017 VB2015Dim VB2013
yourName asVB2012
String * VB2010
10 VB2008 VB6 VB Sample Code 中文VB About Us
VB6 Home Ad
mmhaskell.com
1. Introduction
3.Controls
5.2.2 Scope of Declaration
4. Write Code
Other than using the Dim keyword to declare the data, you can also use other keywords to declare the data. Three other keywords are private ,static and
5. VB Data public. The forms are as shown below:
6. Variables
Private VariableName as Datatype
7. If and IIf( ) Static VariableName as Datatype
Public VariableName as Datatype
VB6 Made Easy Book
The above keywords indicate the scope of the declaration. Private declares a local variable or a variable that is local to a procedure or module. However,
Private is rarely used, we normally use Dim to declare a local variable. The Static keyword declares a variable that is being used multiple times, even after
a procedure has been terminated. Most variables created inside a procedure are discarded by Visual Basic when the procedure is finished, static keyword
preserves the value of a variable even after the procedure is terminated. Public is the keyword that declares a global variable, which means it can be used
by all the procedures and modules of the whole program.
5.3 Constants
Constants are different from variables in the sense that their values do not change during the running of the program.
29. E-library
30. Animation 1
31. Animation 2
32. Animation 3
36. Complie/Distribute
39. Printing
Free Intelligent Writing Tool Mathematical Operations in Data Visualization Tool - Create Visual Basic Sample Codes
40. Creating Report Visual Basic 2010 Interactive dashboards
Full Body 2D Mocap Animation Snakes and Ladders Games Creating Database Using Visual Visual Basic Sample Code
created using visual basic 6 Data Manager in VB6
VB6 Home
Ad Cartoon Animator vbtutor.net vbtutor.net vbtutor.net
1. Introduction
5. VB Data
❮ Previous Lesson Next Lesson ❯
6. Variables
7. If and IIf( )
28 17
8. Select Case
9. Looping
16. Arrays
29. E-library
30. Animation 1
31. Animation 2
32. Animation 3
36. Complie/Distribute
39. Printing