![]() You may select any of the words under the column "Type" in order to use that data type.ĭim intCount As Integer Dim lngHwnd As Long Dim sngPi as Single Dim strName As String Dim dtmBirth As Date Dim blnToggle As Boolean Numeric Data Types Type The following tables describe the data types available in VB6. Variables of certain data types may only contain values which are acceptable for that data type. "Application" means the variable's value will remain throughout running of the programĭata Types are classifications of what sort of data is contained inside of a variable."Procedure" means the variable's value is gone once the procedure its available in has finished."Project" means the variable is available throughout all modules in the project."Module" means the variable is available only within the module in which it was defined."Procedure" means the variable is available only within the Sub, Function, or Property in which it was defined."Module" means the variable is declared near the top of the module, not inside a procedure."Procedure" means the variable is declared within a Sub, Function, or Property.The first word used in a variable declaration.The keyword used to declare a variable and the location in which its declared defines the scope and duration in which a variable is available. Now, go put those lines between Private Sub Form_Load() and End Sub in your program to execute those instructions when the program starts. ![]() In order to use a variable it must first be declared, then its usually modified to represent some sort of value, then its often outputted in some way so that you can see a result from it.Įxample variable declaration, Setting, and Output:ĭim strName as String ' Declares a string called strName strName = "Billy Bob" ' Sets the value of strName strName = strName & " Thornton" ' Appends " Thornton" to strName MsgBox strName ' Outputs the value of strName to a Message Box For example, to save the total marks sustained by a particular person in an integer, use something like int Marks/Marks Sustained rather than a random string of characters. Don't use an ambiguous name like "intUhhhh" or "strX" unless its use is within a very small scope of the program, and even then try not to do it much.Make sure the body of your variable name makes it easy to tell what its used for.Prefix your variable name with the appropriate prefix for your variable's data type.The following are the requirements when naming the variables in Visual Basic:įor the sake of making sure other people can look at your code and know what you were thinking: That data may be an integer like "23", a floating point number like "23.23", a string like "Hello World!", and many other data type. Subs and functions accessible by other programsĪ variable is a word or letter used to reference data used in a program. Description: What its used for most oftenĬontrol object (Like an OCX with source code).Prefix: What people prefix the filename with.You will use various file types while using VB6. These are very important things to remember in order to make your source code more easily intelligible. Because of that, its a handy place to try out the new concepts like the ones you'll be learning in this article. Net.The code that you type between these two lines will be executed when your program launches. These are the major data types in the Visual Basic. An object type variable needs 4 bytes in 32-bit computer and 8 bytes on a 64-bit computer for memory allocation.Ī string type data can hold string values which include 0 to 2 billion Unicode characters. If you declare a variable in Object type, it can hold any type of data. The storage space is same as double type. It needs 8 bytes in memory.Īn integer type variable can store values ranging from -2,147,483,648 to 2,147,483,647. It can hold more range values than integer type, also supports values with decimal points. It stores the values with up to 28 digits after the decimal point. The char type allocates 2 bytes in memory and can store values from o to 65535.Ī date type is used to declare a variable as a date. VB supports the boolean data type which stores only two boolean values true(1) or false(o).Ī byte data type stores the values from 0 to 255 with 1-byte storage allocation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |