Sie sind auf Seite 1von 3

Data types in Visual Basic 6

By default Visual Basic variables are of variant data types. The variant data type can store numeric, date/time or string data. When a variable is declared, a data type is supplied for it that determines the kind of data they can store. The fundamental data types in Visual Basic including variant are integer, long, single, double, string, currency, byte and boolean. Visual Basic supports a vast array of data types. Each data type has limits to the kind of information and the minimum and maximum values it can hold. In addition, some types can interchange with some other types. A list of Visual Basic's simple data types are given below. 1. Numeric Byte Integer Long Store integer values in the range of 0 - 255 Store integer values in the range of (-32,768) - (+ 32,767) Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468) Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038) Store large floating value which exceeding the single data type value store monetary values. It supports 4 digits to the right of decimal point and 15 digits to the left

Single

Double

Currency 2. String

Use to store alphanumeric values. A variable length string can store approximately 4 billion characters 3. Date Use to store date and time values. A variable declared as date type can store both date and time values and it can store date values 01/01/0100 up to 12/31/9999 4. Boolean Boolean data types hold either a true or false value. These are not stored as numeric values and cannot be used as such. Values are internally stored as -1 (True) and 0 (False) and any non-zero value is considered as true.

What is different between Procedure and Function ? Answer:

Procedures
Programmers typically find themselves creating code to perform some action more than once for a given program. When this happens it is time to write a procedure that the program can call from anywhere. This makes testing and maintenance much easier since the code is in only one place. In addition to contributing to a smaller code size, your program can pass arguments to a procedure and enhance its capabilities.

Function
A function procedure is a procedure that executes a set of instructions and returns a value to the calling line of code. Function procedures are normally called from assignment statements which assign a value to a data variable that is the result of the actions performed by the function procedure. For example, if you want to compute an average of two grades, you could write a function procedure that accepts the five grades as parameters and returns the average. The statement to call the function procedure would look like this: AverageGrade = GradeAvgFunction(Grade1, Grade2)

Difference between textbox and RichTextBox ? A simple TextBox can display text without or less formatting i.e it can display all of its Text in same formatting. Like Bold, Italic Underline or combination. You can give it fore color and also change font. That's it! On the other hand, RichTextBox facilitates us to format different parts of text differently. Like 1 Area of text is bold other is normal while another is Bold + Italic+ Underline. You can alo put bullets in RichTextBox, Also set Fore and Background color of text. Also RichTextBox can display tables while Textbox can't. So there are many scenarios where you do need this type of formatting and a simple TextBox is of no use. Exact examples of these 2 are Notepad (TextBox) and WordPad (RichTextBox).

Open both the applications and play with different options. You'll know what is possible with RichTextBox which cant be done with TextBox. If you want a user to input their name then use a TextBox. If you want the user to input what they did for the day, use a RichTextBox.

Das könnte Ihnen auch gefallen