Programas

Páginas: 5 (1233 palabras) Publicado: 15 de julio de 2010
1)
Private Sub Command1_Click()
Dim sumatoria As Integer
Dim n As Integer
Dim i As Integer
n = Val(Texta)
sumatoria = 0
For i = 1 To n
sumatoria = sumatoria + i
Next i
Txtb = Str(sumatoria)
End Sub
2)
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim sumatoria As Integer
Dim i As Integer
Dim j As Integer
Dim nAs Integer
Do
a = Val(Text1)
b = Val(Text2)
Loop While (a < b And a > 0 And b > 0)
sumatoria = a
For i = 1 To b
sumatoria = sumatoria + 1
Next i
Text3 = Str(sumatoria)
If (a Mod 2) = 0 Then
n = a
For j = 1 To b
Text4 = Val(n)
n = n + 2
j = n
Next j
Else
n = a + 1For j = 1 To b
Text4 = Val(n)
n = n + 2
j = n
Next j
End If
End Sub
3) Calculo factorial
Private Sub Command1_Click()
Dim n As Integer
Dim fact As Integer
Dim i As Integer
n = Val(valorn)
fact = 1
If (n = 0 Or n = 1) Then
fact = 1
Else
For i = 1 To n
fact = fact * iNext i
End If
factorial = Str(fact)
End Sub
4) serie Fibonacci
Private Sub Command1_Click()
Dim a, b, n, i, aux As Integer
Dim c As String
i = 1
a = 0
b = 1
Label2.Caption = a
n = Val(Text1.Text)
If n > 0 Then
Do While i <= n
aux = b
b = a + b
a = aux
c = b
Label2.Caption = Label2.Caption + " " + c
i = i + 1
Loop
Else
MsgBox "El número debe sermayor que cero"
End If
End Sub
5) numero mayor a menor
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
If (a > b And a > c) Then
Text4 = Str(a)
If (b > c) Then
Text5 = Str(b)
Text6 = Str(c)
ElseText5 = Str(c)
Text6 = Str(b)
End If
Else
If (b > a And b > c) Then
Text4 = Str(b)
If (a > c) Then
Text5 = Str(a)
Text6 = Str(c)
Else
Text5 = Str(c)
Text6 = Str(a)
End If
Else
Text5 = Str(b)
Text6 = Str(a)Text4 = Str(c)
End If
End If
End Sub
6) números impares
Private Sub Command1_Click()
Dim a, b, i, s As Integer
i = 1
a = Val(Text1.Text)
b = Val(Text2.Text)
If a > b Then
If a > 0 And b > 0 Then
If a Mod 2 = 0 Then
a = a - 1
End If
If b Mod 2 = 0 Then
b = b + 1
End If
For i = b To a
s = s + i
i = i + 1
Next
Label2.Caption = s
Else
MsgBox "Losnúmeros deben ser mayor que cero"
End If
Else
MsgBox "El primer número debe ser mayor que el segundo"
End If
End Sub

7) Programa división por medio de restas sucesivas
Private Sub Command1_Click()
Dim a, b, c, r As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b > 0 Then
If a > b Then
Do While a >= b
a = a - b
c = c + 1
Loop
Text3.Text = c
Text4.Text = a
Else
MsgBox"El primer número debe ser mayor al segundo"
End If
Else
MsgBox "La división para cero no existe. Indeterminación"
End If
End Sub

8) Programa numero primo
Private Sub Command1_Click()
Dim a, i, c As Integer
i = 1
a = Val(Text1.Text)
If a > 0 Then
Do While i <= a
If a Mod i = 0 Then
c = c + 1
End If
i = i + 1
Loop
If c = 2 Then
Label2.Caption = "Número primo"
ElseLabel2.Caption = "Número no es primo"
End If
Else
MsgBox "El número debe ser mayor que cero"
End If
End Sub
9)
Private Sub Command1_Click()
Dim n As Integer
Dim i As Integer
Dim j As Integer
Dim Cad As String
n = Val(Text1)
j = 1
Cad = ""
For i = 1 To n
If (i Mod 2) <> 0 Then
If (i Mod 3) <> 0 Then
If (i Mod 5)...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Programa
  • Program
  • Un Programa
  • Programas
  • Programas
  • Programa
  • Programador
  • Program

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS