El documento describe los tipos de datos en Visual Basic .NET, incluyendo el tipo, la estructura de tipo Common Language Runtime, la asignación de almacenamiento nominal y los intervalos de valores. Se enumeran tipos como enteros, decimales, fechas, cadenas y objetos, y se especifican sus rangos de valores. También incluye un ejemplo de código para una aplicación que realiza cálculos matemáticos básicos utilizando estos tipos de datos.
1. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
PRACTICA Nº 02PRACTICA Nº 02PRACTICA Nº 02PRACTICA Nº 02
TIPOS DE DATOS
En la tabla siguiente se muestran los tipos de datos de Visual Basic
Language Runtime, su asignación de almacenamiento nominal y sus intervalos de valores.
Tipo de Visual
Basic
Estructura de
tipo Common
Language
Runtime
Asignación de
almacenamiento
nominal
Boolean Boolean
En función de la
plataforma de
implementación
Byte Byte 1 byte
Char (carácter
individual)
Char 2 bytes
Fecha DateTime 8 bytes
Decimal Decimal 16 bytes
Double (punto
flotante de
precisión
doble)
Double 8 bytes
Integer Int32 4 bytes
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
En la tabla siguiente se muestran los tipos de datos de Visual Basic .NET, los tipos compatibles con Common
Language Runtime, su asignación de almacenamiento nominal y sus intervalos de valores.
Asignación de
almacenamiento
nominal
Intervalo de valores
En función de la
plataforma de
implementación
True o False
1 byte 0 a 255 (sin signo)
2 bytes 0 a 65535 (sin signo)
8 bytes
0:00:00 (medianoche) del 1 de enero de 0001 a
11:59:59 p.m. del 31 de diciembre de 9999.
16 bytes
0 a +/-79.228.162.514.264.337.593.543.950.335 (+/
7,9... E+28) † sin separador decimal; 0 a +/
7,9228162514264337593543950335 con 28 posiciones
a la derecha del decimal;
el número distinto de cero más pequeño es +/
0,0000000000000000000000000001 (+/
8 bytes
-1,79769313486231570E+308 a
4,94065645841246544E-324 † para los valores
negativos;
4,94065645841246544E-324 a
1,79769313486231570E+308 † para los valores
positivos
4 bytes -2.147.483.648 a 2.147.483.647 (con signo)
Gelbert Edson Totora Tarapa
[1]
.NET, los tipos compatibles con Common
Language Runtime, su asignación de almacenamiento nominal y sus intervalos de valores.
0:00:00 (medianoche) del 1 de enero de 0001 a
11:59:59 p.m. del 31 de diciembre de 9999.
79.228.162.514.264.337.593.543.950.335 (+/-
7,9... E+28) † sin separador decimal; 0 a +/-
7,9228162514264337593543950335 con 28 posiciones
el número distinto de cero más pequeño es +/-
0,0000000000000000000000000001 (+/-1E-28) †
1,79769313486231570E+308 a -
324 † para los valores
1,79769313486231570E+308 † para los valores
2.147.483.648 a 2.147.483.647 (con signo)
2. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
Long (entero
largo)
Int64 8 bytes
Objeto. Object (clase)
4 bytes en
plataforma de 32
bits
8 bytes en
plataforma de 64
bits
SByte SByte 1 byte
Short (entero
corto)
Int16 2 bytes
Single (punto
flotante de
precisión
sencilla)
Single 4 bytes
String
(longitud
variable)
String (clase)
En función de la
plataforma de
implementación
UInteger UInt32 4 bytes
ULong UInt64 8 bytes
User-Defined
(estructura)
(hereda de
ValueType)
En función de la
plataforma de
implementación
UShort UInt16 2 bytes
† En notación cienơfica, E hace referencia a una potencia de 10. Por consiguiente, 3,56E+2 significa 3.56 x
102 ó 356 y 3,56E-2 significa 3.56 / 102 ó 0,0356.
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
8 bytes
-9.223.372.036.854.775.808 a
9.223.372.036.854.775.807 (9,2...E+18 †) (con signo)
4 bytes en
plataforma de 32
bits
8 bytes en
plataforma de 64
bits
Cualquier tipo puede almacenarse en una variable de
tipo Object
1 byte -128 a 127 (con signo)
2 bytes -32.768 a 32.767 (con signo)
4 bytes
-3,4028235E+38 a -1,401298E-45 † para los valores
negativos;
1,401298E-45 a 3,4028235E+38 † para los valores
positivos
En función de la
plataforma de
implementación
0 a 2.000 millones de caracteres Unicode aprox.
4 bytes 0 a 4.294.967.295 (sin signo)
8 bytes
0 a 18.446.744.073.709.551.615 (1,8...E+19 †) (sin
signo)
En función de la
plataforma de
implementación
Cada miembro de la estructura tiene un intervalo de
valores determinado por su tipo de datos y es
independiente de los intervalos de valores
correspondientes a los demás miembros.
2 bytes 0 a 65.535 (sin signo)
† En notación cienơfica, E hace referencia a una potencia de 10. Por consiguiente, 3,56E+2 significa 3.56 x
2 significa 3.56 / 102 ó 0,0356.
Gelbert Edson Totora Tarapa
[2]
9.223.372.036.854.775.807 (9,2...E+18 †) (con signo)
Cualquier tipo puede almacenarse en una variable de
45 † para los valores
45 a 3,4028235E+38 † para los valores
0 a 2.000 millones de caracteres Unicode aprox.
0 a 18.446.744.073.709.551.615 (1,8...E+19 †) (sin
Cada miembro de la estructura tiene un intervalo de
valores determinado por su tipo de datos y es
ndiente de los intervalos de valores
correspondientes a los demás miembros.
† En notación cienơfica, E hace referencia a una potencia de 10. Por consiguiente, 3,56E+2 significa 3.56 x
3. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
APLICACIÓN PRÁCTICA
Abir Nuevo Proyecto Archivo – Nuevo Proyecto
En Nombre Colocar Practica-02
1.- Diseñar el siguiente formulario:
2.- Cambiar las propiedades de los objetos como sigue:
Objeto
Form1
Label1
Label2
Label3
TextBox1
TextBox2
TextBox3
Button1
Button2
Button3
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
Nuevo Proyecto – Seleccionar Aplicación de Windows Forms
Diseñar el siguiente formulario:
Cambiar las propiedades de los objetos como sigue:
Propiedad Valor
Name FrmCalculo
Text Calculo de Numeros
MaximizeBox False
Text Numero 1:
Text Numero 2:
Text Respuesta :
Name TxtNro1
BorderStyle FixedSingle
Name TxtNro2
BorderStyle FixedSingle
Name TxtRpta
BorderStyle FixedSingle
Locked True
Name BtnNuevo
Text Sumar
FlatStyle Popup
Name BtnSumar
Text Sumar
FlatStyle Popup
Name BtnRestar
Text Restar
FlatStyle Popup
Gelbert Edson Totora Tarapa
[3]
Seleccionar Aplicación de Windows Forms.
Valor
Numeros
4. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
Button4
Button5
Button6
3.- En la Vista de Código insertar el siguiente código:
' variables de ambito global
Dim Nro1 As Decimal
Dim Nro2 As Decimal
Dim Rpta As Decimal
Private Sub BtnSumar_Click(
BtnSumar.Click
' Comprobacion de que no este vacio el texto
If (TxtNro1.Text = "")
MsgBox("Debe llenar el Campo Numero 1."
TxtNro1.Focus()
Exit Sub
End If
If (TxtNro2.Text = "")
MsgBox("Debe llenar el Campo Numero 2."
TxtNro1.Focus()
Exit Sub
End If
' comprobacion de que los datos ingresados sean numeros
If (IsNumeric(TxtNro1.Text))
Nro1 = CDec(TxtNro1.Text)
Else
MsgBox("Debe Ingresar Numeros."
TxtNro1.Text = ""
TxtNro1.Focus()
Exit Sub
End If
If (IsNumeric(TxtNro2.Text))
Nro2 = CDec(TxtNro2.Text)
Else
MsgBox("Debe Ingresar
TxtNro2.Text = ""
TxtNro2.Focus()
Exit Sub
End If
' Operacion de Suma
Rpta = Nro1 + Nro2
TxtRpta.Text = CStr(Rpta)
End Sub
Private Sub BtnRestar_Click(
BtnRestar.Click
' Comprobacion de que no este vacio el texto
If (TxtNro1.Text = "")
MsgBox("Debe llenar el Campo Numero 1."
TxtNro1.Focus()
Exit Sub
End If
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
Name BtnMultiplicar
Text Multiplicar
FlatStyle Popup
Name BtnDividir
Text Dividir
FlatStyle Popup
Name BtnSalir
Text Salir
FlatStyle Popup
En la Vista de Código insertar el siguiente código:
BtnSumar_Click(ByVal sender As System.Object, ByVal e As System.
' Comprobacion de que no este vacio el texto
) Then
"Debe llenar el Campo Numero 1.", MsgBoxStyle.Information, "Advertencia"
) Then
"Debe llenar el Campo Numero 2.", MsgBoxStyle.Information, "Advertencia"
' comprobacion de que los datos ingresados sean numeros
(IsNumeric(TxtNro1.Text)) Then
(TxtNro1.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(IsNumeric(TxtNro2.Text)) Then
(TxtNro2.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(Rpta)
BtnRestar_Click(ByVal sender As System.Object, ByVal e As System.
' Comprobacion de que no este vacio el texto
) Then
"Debe llenar el Campo Numero 1.", MsgBoxStyle.Information, "Advertencia"
Gelbert Edson Totora Tarapa
[4]
BtnMultiplicar
System.EventArgs) Handles
"Advertencia")
"Advertencia")
"Advertencia")
"Advertencia")
System.EventArgs) Handles
"Advertencia")
5. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
If (TxtNro2.Text = "")
MsgBox("Debe llenar el Campo Numero 2."
TxtNro1.Focus()
Exit Sub
End If
' comprobacion de que los datos ingresados sean numeros
If (IsNumeric(TxtNro1.Text))
Nro1 = CDec(TxtNro1.Text)
Else
MsgBox("Debe Ingresar Numeros."
TxtNro1.Text = ""
TxtNro1.Focus()
Exit Sub
End If
If (IsNumeric(TxtNro2.Text))
Nro2 = CDec(TxtNro2.Text)
Else
MsgBox("Debe Ingresar
TxtNro2.Text = ""
TxtNro2.Focus()
Exit Sub
End If
' Operacion de Resta
Rpta = Nro1 - Nro2
TxtRpta.Text = CStr(Rpta)
End Sub
Private Sub BtnMultiplicar_Click(
Handles BtnMultiplicar.Click
' Comprobacion de que no este vacio el texto
If (TxtNro1.Text = "")
MsgBox("Debe llenar el Campo
TxtNro1.Focus()
Exit Sub
End If
If (TxtNro2.Text = "")
MsgBox("Debe llenar el Campo Numero 2."
TxtNro1.Focus()
Exit Sub
End If
' comprobacion de que los datos ingresados sean numeros
If (IsNumeric(TxtNro1.Text))
Nro1 = CDec(TxtNro1.Text)
Else
MsgBox("Debe Ingresar N
TxtNro1.Text = ""
TxtNro1.Focus()
Exit Sub
End If
If (IsNumeric(TxtNro2.Text))
Nro2 = CDec(TxtNro2.Text)
Else
MsgBox("Debe Ingresar Numeros."
TxtNro2.Text = ""
TxtNro2.Focus()
Exit Sub
End If
' Operacion de Multiplicacion
Rpta = Nro1 * Nro2
TxtRpta.Text = CStr(Rpta)
End Sub
Private Sub BtnDividir_Click(
BtnDividir.Click
' Comprobacion de que no este vacio el texto
If (TxtNro1.Text = "")
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
) Then
"Debe llenar el Campo Numero 2.", MsgBoxStyle.Information, "Advertencia"
' comprobacion de que los datos ingresados sean numeros
(IsNumeric(TxtNro1.Text)) Then
(TxtNro1.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(IsNumeric(TxtNro2.Text)) Then
(TxtNro2.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(Rpta)
BtnMultiplicar_Click(ByVal sender As System.Object, ByVal e As
' Comprobacion de que no este vacio el texto
) Then
"Debe llenar el Campo Numero 1.", MsgBoxStyle.Information, "Advertencia"
) Then
"Debe llenar el Campo Numero 2.", MsgBoxStyle.Information, "Advertencia"
' comprobacion de que los datos ingresados sean numeros
(IsNumeric(TxtNro1.Text)) Then
(TxtNro1.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(IsNumeric(TxtNro2.Text)) Then
(TxtNro2.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
' Operacion de Multiplicacion
Rpta)
BtnDividir_Click(ByVal sender As System.Object, ByVal e As System.
' Comprobacion de que no este vacio el texto
) Then
Gelbert Edson Totora Tarapa
[5]
"Advertencia")
"Advertencia")
"Advertencia")
System.EventArgs)
"Advertencia")
"Advertencia")
"Advertencia")
"Advertencia")
System.EventArgs) Handles
6. PROGRAMACION CON VISUAL BA
CEPRO EXE-TEC
Computación e Informática
MsgBox("Debe llenar el Campo Numero 1."
TxtNro1.Focus()
Exit Sub
End If
If (TxtNro2.Text = "")
MsgBox("Debe llenar el Campo Numero 2."
TxtNro1.Focus()
Exit Sub
End If
' comprobacion de que los datos ingresados sean numeros
If (IsNumeric(TxtNro1.Text))
Nro1 = CDec(TxtNro1.Text)
Else
MsgBox("Debe Ingresar Numeros."
TxtNro1.Text = ""
TxtNro1.Focus()
Exit Sub
End If
If (IsNumeric(TxtNro2.Text))
Nro2 = CDec(TxtNro2.Text)
Else
MsgBox("Debe Ingresar Numeros."
TxtNro2.Text = ""
TxtNro2.Focus()
Exit Sub
End If
If (Nro2 = 0) Then
MsgBox("Imposible la Division
Exit Sub
End If
' Operacion de Division
Rpta = Nro1 / Nro2
TxtRpta.Text = CStr(Rpta)
End Sub
Private Sub BtnSalir_Click(
BtnSalir.Click
Me.Close()
End Sub
Private Sub BtnNuevo_Click(
BtnNuevo.Click
TxtNro1.Clear()
TxtNro2.Clear()
TxtRpta.Clear()
TxtNro1.Focus()
End Sub
ASIC 2010 Ing. Gelbert Edson Totora Tarapa
Computación e Informática
llenar el Campo Numero 1.", MsgBoxStyle.Information, "Advertencia"
) Then
"Debe llenar el Campo Numero 2.", MsgBoxStyle.Information, "Advertenc
' comprobacion de que los datos ingresados sean numeros
(IsNumeric(TxtNro1.Text)) Then
(TxtNro1.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
(IsNumeric(TxtNro2.Text)) Then
(TxtNro2.Text)
"Debe Ingresar Numeros.", MsgBoxStyle.Information, "Advertencia"
"Imposible la Division entre cero.", MsgBoxStyle.Information,
' Operacion de Division
(Rpta)
BtnSalir_Click(ByVal sender As System.Object, ByVal e As System.
BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.
Gelbert Edson Totora Tarapa
[6]
"Advertencia")
"Advertencia")
"Advertencia")
"Advertencia")
.Information, "Advertencia")
System.EventArgs) Handles
System.EventArgs) Handles