viernes, 2 de julio de 2010

Reseñas de Comandos para utilizar Visual Basic

Ejemplo 1:

Function EJEM3(a, b, c)
If a > b And b > c Then
EJEM3 = "A es el mayor"
End If
If b > a And b > c Then
EJEM3 = "B es el mayor"
End If
If c > a And c > b Then
EJEM3 = "C es mayor"
End If
If a = b And b = c Then
EJEM3 = "Todos son iguales"
End If
End Function

Ejemplo 2:
Option Explicit
Private Sub CommandButton1_Click()
Dim montoprestamo As Double
Dim interes As Double
Dim ncuotas As Double
Dim cuotaspagadas As Double
Dim interesfecha As Double
Dim total As Double
montoprestamo = Val(TextBox1)
Cells(8, 1) = montoprestamo
interes = Val(TextBox2)
Cells(8, 2) = interes
ncuotas = Val(TextBox3)
Cells(8, 3) = ncuotas
cuotaspagadas = Val(TextBox4)
Cells(8, 4) = cuotaspagadas
interesfecha = montoprestamo * (((1 + (interes / 100)) ^ (ncuotas - cuotaspagadas)) - 1)
TextBox5 = interesfecha
Cells(8, 5) = interesfecha
total = ((montoprestamo / (ncuotas)) * cuotaspagadas) + interesfecha
TextBox6 = total
Cells(8, 6) = total
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub TextBox1_Change()
End Sub

Ejemplo 3:
Private Sub CommandButton1_Click()
Selection.EntireRow.Insert
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
TextBox4 = Empty
TextBox5 = Empty
TextBox6 = Empty
TextBox1.SetFocus
End Sub
Private Sub CommandButton2_Click()
Dim MONTOTIPO As Double
Dim diatrabajado As Double
If TextBox6 = "AG" Then
MONTOTIPO = 25000 * Val(TextBox2)
bono = 35000
ElseIf TextBox6 = "FO" Then
MONTOTIPO = 5000 * Val(TextBox2)
bono = 8000
ElseIf TextBox6 = "OF" Then
TextBox1 = "HOLA"
Else
MsgBox "TIPO DE PROFESIONAL NO RECONOCIDO"
End If
diastrabajo = Val(TextBox2)
TextBox3 = MONTOTIPO / diastrabajo
TextBox4 = bono
TextBox5 = MONTOTIPO + bono
End Sub
Private Sub CommandButton3_Click()
If Row2 = Empty Then
Selection.EntireRow.Delete
End If
End
End Sub


Ejemplo 4:
Private Sub TextBox1_Change()
Range("A2").Select
ActiveCell.FormulaR1C1 = TextBox1
End Sub
Private Sub TextBox2_Change()
Range("B2").Select
ActiveCell.FormulaR1C1 = TextBox2
End Sub
Private Sub TextBox3_Change()
Range("C2").Select
ActiveCell.FormulaR1C1 = TextBox3
End Sub
Private Sub TextBox4_Change()
Range("D2").Select
ActiveCell.FormulaR1C1 = TextBox4
End Sub
Private Sub TextBox5_Change()
Range("E2").Select
ActiveCell.FormulaR1C1 = TextBox5
End Sub
Private Sub TextBox6_Change()
Range("F2").Select
ActiveCell.FormulaR1C1 = TextBox6
End Sub

Ejemplo 5:
Private Sub CommandButton1_Click()
Dim a As Double
Dim b As Double
Dim c As Double
a = TextBox1
Cells(9, 1) = a
b = TextBox2
Cells(9, 2) = b
c = a ^ (1 / b)
TextBox3 = c
Cells(9, 3) = c
End Sub
Private Sub CommandButton2_Click()
End
Beep
End Sub
Private Sub TextBox1_Change()
End Sub

No hay comentarios:

Publicar un comentario