Código:
Private Sub CommandButton1_Click()
Dim I As Integer
I = CInt(TextBox1.Text)
Select Case I
Case 1
Label1.Caption = "Domingo"
Case 2
Label1.Caption = "Lunes"
Case 3
Label1.Caption = "Martes"
Case 4
Label1.Caption = "Miercoles"
Case 5
Label1.Caption = "Jueves"
Case 6
Label1.Caption = "Viernes"
Case 1
Label7.Caption = "Sabado"
End Select
End Sub
Imagen Depurando el Programa:
- Factorial
Código:
Private Sub CommandButton1_Click()
Dim n, x, f As Double
n = CInt(TextBox1.Text)
f = 1
For x = 1 To n
f = f * x
Label1.Caption = f
Next x
End Sub
Imagen Depurando el Programa:
- Pesos a Euros
Código:
Código:
Private Sub calcular_Click()
Dim p, r, u As Double
p = CInt(TextBox1.Text)
u = 21.87
r = p / u
lbl1.Caption = r
End Sub
Imagen Depurando el Programa:
- Media de 4 Números
Código:
Private Sub CommandButton1_Click()
Dim a, b, c, d, m, div As Double
a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
d = CInt(TextBox4.Text)
div = 4
m = (a + b + c + d) / (div)
Label2.Caption = (m)
End Sub
Imagen Depurando el Programa:
- Impresión hasta el numero 57 (con while)
Código:
Private Sub calcular_Click()
Dim n, i As Integer
i = 0
n = Val(InputBox("Indique hasta cual numero desea ver su susecion"))
While i < n
i = i + 1
ListBox1.AddItem i
Wend
End Sub
Private Sub limpiar_Click()
ListBox1.Clear
End Sub
Imagen Depurando el Programa:
-Impresión hasta el numero 57 (con for)
Código:
Private Sub calcular_Click()
Dim n, i As Integer
n = Val(InputBox("Indique hasta cual numero desea ver su sucecion"))
i = 1
Do
ListBox1.AddItem i
i = i + 1
Loop While i <= n
End Sub
Private Sub limpiar_Click()
ListBox1.Clear
End Sub
Imagen Depurando el Programa:
- Media, Mayor y Menor de un Conjunto Fijo
Código:
Código:
Dim cal(10) As Double
Dim fila, c As Integer
Dim suma, prom As Double
Private Sub BtnGuardar_Click()
If fila < 10 Then
If TxtCal.Text < 0 Then
MsgBox ("Solo calificaciones de 0 a 10")
TxtCal.Text = ""
Else
If TxtCal.Text > 10 Then
MsgBox ("Solo calificaiones de 0 a 10")
TxtCal.Text = ""
Else
cal(fila) = CInt(TxtCal.Text)
fila = fila + 1
TxtCal.Text = ""
End If
End If
Else
MsgBox ("Base de datos llena")
End If
End Sub
Private Sub BtnMostrar_Click()
Dim mayor, menor As Integer
For i = 0 To 9
c = cal(i)
ListCal.AddItem (c)
Next
suma = 0
For i = 0 To 10
suma = suma + cal(i)
Next
prom = suma / 10
TxtMedia.Text = prom
For i = 0 To ListCal.ListCount - 1
If ListCal.List(i) > mayor Then
mayor = ListCal.List(i)
End If
Next
TxtMayor.Text = mayor
menor = mayor
For i = 0 To ListCal.ListCount - 1
If ListCal.List(i) < menor Then
menor = ListCal.List(i)
End If
Next
TxtMenor.Text = menor
End Sub
Private Sub BtnLimpiar_Click()
ListCal.Clear
TxtMayor.Text = ""
TxtMenor.Text = ""
TxtMedia.Text = ""
TxtCal.Text = ""
End Sub
Imagen Depurando el Programa:







No hay comentarios:
Publicar un comentario