Practica 2

Descargar como txt, pdf o txt
Descargar como txt, pdf o txt
Está en la página 1de 4

Public Sub pista()

MsgBox "EJERCICIO 1"

Dim L, a, area As Integer

a = InputBox("Cual es el ancho de la pista? ")


L = 100

If a > 0 Then area = a * L


MsgBox "La pista de " & L & " metros de largo x " & a & " metros de ancho,
Tiene un Area de " & area & " m^2"
End Sub
Public Sub sucesion()

Dim num, serie As Integer


MsgBox "EJERCICIO 2"
serie = InputBox("Largo de la serie: ")
num = 3

For i = 3 To serie
num = i
num = num * num
MsgBox "Serie " & num
Next
End Sub

Public Sub sucesionii()


Dim serie, n, a, num As Integer
Dim b As String
MsgBox "EJERCICIO 2"
serie = InputBox("¿cuantos valores deseas?: ", "serie")
a = serie + 2
For n = 3 To a
num = n * n
b = b & " " & num
Next
MsgBox "serie: " & b

End Sub
Public Sub numenterol()
Dim n As Integer
Dim b1, b2, h, area, i As Integer
MsgBox "EJERCICIO 3"

n = InputBox("Hasta que número quiere que genere?")

If n <= 0 Then
MsgBox "El número tiene que ser mayor a 0"
Else
For i = 1 To 10
b1 = Int((n * Rnd) + 1)
b2 = Int((n * Rnd) + 1)
h = Int((n * Rnd) + 1)
area = h + ((b1 * b2) / 2)
MsgBox "Area del Trapecio " & i & ": " & area & " m^2"

Next

End If
End Sub

Public Sub numenteroll()


Dim n As Integer
Dim b1, b2, h, area, i As Integer

MsgBox "EJERCICIO 4"

n = InputBox("Hasta que número quiere que genere?")

If n <= 0 Then
MsgBox "El número tiene que ser mayor a 1"
Else
For i = 1 To 10
b1 = (Int((n * Rnd) + 1)) * 2
b2 = (Int((n * Rnd) + 1)) * 2
h = (Int((n * Rnd) + 1)) * 2
area = h + ((b1 * b2) / 2)
MsgBox "Area del Trapecio " & i & ": " & area & " m^2"
Next
End If
End Sub

Public Sub cuadrados()


Dim numCuadrados, i, j, Lado, area As Integer
Dim cuadrados() As Integer
MsgBox "EJERCICIO 5"
numCuadrados = InputBox("Cuantos cuadrados quieres crear")

ReDim cuadrados(numCuadrados)

For i = 0 To numCuadrados
Lado = InputBox("Ingrese el lado del cuadrado")
cuadrados(i) = Lado
For j = 0 To (i - 1)
If i = 0 Then

Else
Do While cuadrados(j) = Lado
Lado = InputBox("Este cuadrado ya está creado, Ingrese
otro")
Loop
End If
Next
area = Lado * Lado
MsgBox "El cuadrado " & i & ": " & area & " de area"
Next

End Sub
Public Sub cuadradosll()
Dim L As Double, a As Double
MsgBox "EJERCICIO 5"
L = InputBox("ingrese el lado del cuadrado (cm): ", "creacion de cuadrado")
a = L * L
MsgBox " se genero un cuadrado de " & a & " cm2", vbInformation, "creacion de
cuadrado"

End Sub
Public Sub parabola()
Dim x, y As Double

MsgBox "EJERCICIO 6"

y = ((x - 0.5) * (-0 - 5)) - 0.25


MsgBox "el vertice de la parabola es: " & " (0,0)*&*; los inersectos en x e y son:
" & " x=0, x=1 " & ", y=0.25"

End Sub
Public Sub cordon()
Dim Ancho, Longitud, Perimetro, area As Integer
MsgBox "EJERCICIO 7"

Ancho = 40
Longitud = 20

Do While Ancho > 0


Perimetro = 2 * (Ancho + Longitud)
area = (Ancho * Longitud)
MsgBox "Ancho: " & Ancho & vbCrLf & "Longitud: " & Longitud & vbCrLf &
"Perimetro: " & Perimetro & vbCrLf & "El area es: " & area

Longitud = Longitud + 1
Ancho = Ancho - 1

Loop
End Sub

Public Sub area()


Dim radio, altura, area, volumen As Integer
MsgBox "EJERCICIO 8"

radio = InputBox("Escriba el radio del cilindro")


altura = InputBox("Escriba la altura del cilindro")

If (radio > 0 And altura > 0) Then


area = radio * radio
volumen = area * altura

MsgBox "El volumen es: " & volumen & "Pi cm^3"
End If
End Sub

Public Sub cajarectangular()

Dim x, h, a As Long

x = InputBox("Ingresa la Longitud de la base 'X' ")

If x > 0 Then
h = (16000 / (x * x)) * 2
a = (4 * x * 16000 / (x * x)) + (x * x)
Else
MsgBox "La base tiene que ser un número mayor a 0"
End If

MsgBox "El area de la Caja con respecto a la longitud " & x & " es: " & a & "
cm^2"
End Sub

También podría gustarte