Partilhar via


Tipos de dados no Visual Basic

The data type of a programming element refers to what kind of data it can hold and how it stores that data. Data types apply to all values that can be stored in computer memory or participate in the evaluation of an expression. Every variable, literal, constant, enumeration, property, procedure parameter, procedure argument, and procedure return value has a data type.

Declared Data Types

Unless you use typeless programming, you must declare data types for all your programming elements. (For more information, see Programação Sem-Tipos no Visual Basic.)

You define a programming element with a declaration statement, and you specify its data type with the As clause. The following table shows the statements you use to declare various elements.

Programming element

Data type declaration

Variable

In a Instrução Dim (Visual Basic)

Dim amount As Double

Static yourName As String

Public billsPaid As Decimal = 0

Literal

With a literal type character; see "Literal Type Characters" in Caracteres de tipo (Visual Basic)

Dim searchChar As Char = "."C

Constant

In a Declaração Const (Visual Basic)

Const modulus As Single = 4.17825F

Enumeration

In an Declaração Enum (Visual Basic)

Public Enum colors

Property

In a Propriedade declaração

Property region() As String

Procedure parameter

In a Instrução Sub (Visual Basic), Instrução Function (Visual Basic), or Instrução Operator

Sub addSale(ByVal amount As Double)

Procedure argument

In the calling code; each argument is a programming element that has already been declared, or an expression containing declared elements

subString = Left(inputString, 5)

Procedure return value

In a Instrução Function (Visual Basic) or Instrução Operator

Function convert(ByVal b As Byte) As String

Consulte também

Tarefas

Solucionando problemas de tipos de dados (Visual Basic)

Referência

Resumo de tipo de dados (Visual Basic)

Conceitos

Caracteres de tipo (Visual Basic)

Tipos de dados de composição (Visual Basic)

Tipos genéricos no Visual Basic (Visual Basic)

Programação Sem-Tipos no Visual Basic

Outros recursos

Tipos de dados elementares (Visual Basic)

Implementação de tipos de dados (Visual Basic)

Conversões de Tipo no Visual Basic

Estruturas (Visual Basic)