Handling various types of data in visual basic 6.0

There is an assumption that working with visual basic program means working with database scope, it's not entirely true. However, the data can be processed by the visual basic could be internal data and external data.

Internal data is data that is instantly recognizable by the computer because the data is stored in computer memory (RAM). While the external data is data that is stored outside the processing device (Floppy disks, hard disks, CD, tape, USB and others).

Use of operators and functions on data of characters types.
Data of characters type is the type most frequently used data, where these data types can be used for data Alphanumeric (Alphabetic and Numeric). So with this data type you can enter data alphabet, numbers, dates, and other data.

Generally it's said that the data have a character data type when the data is marked with quotes. All alphabets that displayed on the keyboard is a data type of character. Some functions are reserved for the data of characters type are:

1. &
Function of the operator "&" is to combine the data, either the data of character type, numeric or date and time.
Type: &
Example: MsgBox "Learning Visual Basic " & 6 & " [Start date: " & Date & "]"
Result: Learning Visual Basic 6 [Start date: 21/03/2012]

2. Left
This function is used to cut the character, from the left as many as N characters.
Type: Left(<String>, N)
Example: MsgBox Left("Ambarhalim", 5)
Result: Ambar

3. Right
This function is used to cut the character, from the right as many as N characters.
Type: Right(<String>, N)
Example: MsgBox Right("Ambarhalim", 5)
Result: halim

4. Mid
This function is used to cut the character, from the P position as many as N characters.
Type: Mid(<String>, P, N)
Example: MsgBox Mid("Ambarhalim.blogspot.com", 6, 10)
Result: halim.blog

5. Len
This function is used to calculate the number of characters.
Type: Len(<String>)
Example: MsgBox Len("Ambarhalim.blogspot.com")
Result: Number of characters is: 23

6. UCase
This function is used to convert all characters to UPPERCASE.
Type: UCase(<String>)
Example: MsgBox UCase("ambarhalim")
Result: AMBARHALIM

7. LCase
This function is used to convert all characters to lowercase.
Type: LCase(<String>)
Example: MsgBox LCase("AMBARHALIM")
Result: ambarhalim

8. Trim
This function is used to remove the spaces left and right.
Type: Trim(<String>)
Example: MsgBox "You" & Trim(" And ") & "Me"
Result: YouAndMe

9. RTrim
This function is used to eliminate the blank space to the right.
Type: RTrim(<String>)
Example: MsgBox "You" & RTrim(" And ") & "Me"
Result: You AndMe

10. LTrim
This function is used to eliminate the blank space to the left.
Type: LTrim(<String>)
Example: MsgBox "You" & LTrim(" And ") & "Me"
Result: YouAnd Me

11. Val
This function is used to convert a string into a numeric value.
Type: Val(<String>)
Example: MsgBox Val("1 23 4")
Result: 1234

The format and function on data of numeric type.
Data of numeric types are data types that are only used to store or operate the numeric data. With these data types, mathematical calculations can be done well even be done at a very high degree of accuracy. Given a numeric data type is only for the number data, preferably in the use of numeric data is not covered or restricted by quotes ("") for the string or sign (##) for date and time.

Some functions are reserved for the data of numeric type are: 

1. Int
This function is used to generate integers.
Type: Int(<Number>)
Example: MsgBox Int(4.98)
Result: 4

2. Mod
This function is divides two numbers and returns only the remainder.
Type: <Number> Mod <Number>
Example: [#1] MsgBox 6 Mod 9, [#2] MsgBox 9 Mod 6
Result: [#1] 6, [#2] 3

3. Abs
This function is used to generate absolute numbers.
Type: Abs(<Number>)
Example: MsgBox Abs(-4.98)
Result: 4,98

4. Sqr
This function is used to determine the square root.
Type: Sqr(<Number>)
Example: MsgBox Sqr(81)
Result: 9

5. Sum
This function is used to add a value of the query command.
Type: Sum(<Field>)
Example of use: Select Sum(Salary) As Total_Salary From Employee

6. Count
This function is used to calculate the amount of data in the query command..
Type: Count(<Field>)
Example of use: Select Count(Material_Name) As Total From Material

7. Avg
This function is used to calculate the average value of the query command.
Type: Avg(<Field>)
Example of use: Select Avg(Salary) As Avg_Salary From Employee

8. Max
This function is used to generate the greatest value of the query command.
Type: Max(<Field>)
Example of use: Select Max(Salary) As Greatest_Salary From Employee

9. Min
This function is used to produce the smallest value of the query command.
Type: Min(<Field>)
Example of use: Select Min(Salary) As Smallest_Salary From Employee

10. Sin
This function is used to generate sine values​​.
Type: Sin(<Number>)

11. Cos
This function is used to generate the cosine.
Type: Cos(<Number>)
 
12. Tan
This function is used to generate the tangent.
Type: Tan(<Number>)
 
13. Format(,"#,#,##")
This function is used to format the display numbers in thousands, millions and so on, as well as a decimal value.
Type: Format(,"#,#,##")
Example of use: Format(5710000,"#,#,##")
Result: 5.710.000


Keyword: Handling various types of data in visual basic 6.0 | visual basic data type

You may also like: