Está en la página 1de 8

(' explica cada función)

' definicion de variables

Dim num1 As Double 'variable doble permite números décimales

Dim num2 As Double 'variable doble permite números décimales

Dim op As String 'variable de texto para seleccionar la operación

Private Sub CommandButton1_Click()

' boton para ingresar el numero 1

TextBox1.Text = TextBox1.Text & 1

End Sub

Private Sub CommandButton10_Click()

' boton para ingresar el numero

TextBox1.Text = TextBox1.Text & 0

End Sub

Private Sub CommandButton11_Click()

' boton para ingresar la operacion multiplicación

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto

op = "*" ' asigna a la variable op el texto "*"

TextBox1.SetFocus 'configura el cursor en el primer espacio del cuadr de texto

End Sub

Private Sub CommandButton12_Click()

' boton para ingresar la operacion división

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto


op = "/" ' asigna a la variable op el texto "/"

TextBox1.SetFocus 'configura el cursor en el primer espacio del cuadr de textos

End Sub

Private Sub CommandButton13_Click()

' boton para ingresar la operacion de porcentaje

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto

op = "%" ' asigna a la variable op el texto "%"

TextBox1.SetFocus 'configura el cursor en el primer espacio del cuadr de texto

End Sub

Private Sub CommandButton14_Click()

' boton para ingresar la operacion suma

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto

op = "+" ' asigna a la variable op el texto "+"

TextBox1.SetFocus 'configura el cursor en el primer espacio del cuadr de texto

End Sub

Private Sub CommandButton15_Click()

' boton para ingresar la operacion resta

' condicion para ingresar un numero negativo

If TextBox1.Text = "" Then

TextBox1.Text = TextBox1.Text & "-"

Else

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1
TextBox1.Text = "" ' limpia el cuadro de texto

op = "-" ' asigna a la variable op el texto "-"

TextBox1.SetFocus 'configura el cursor en el primer espacio del cuadr de texto

End If

End Sub

Private Sub CommandButton16_Click()

' boton igual se ejecutan las operaciones

If (num1 = 0) Then

MsgBox ("No se realizo una operación")

Else

num2 = TextBox1.Text

'suma

If op = "+" Then

TextBox1.Text = num1 + num2

End If

'resta

If op = "-" Then

TextBox1.Text = num1 - num2

End If

'división

If op = "/" Then

TextBox1.Text = num1 / num2

End If
'producto

If op = "*" Then

TextBox1.Text = num1 * num2

End If

' raiz

If op = "R" Then

TextBox1.Text = num1 ^ (1 / num2)

End If

' exponente

If op = "ex" Then

TextBox1.Text = num1 ^ num2

End If

' porcentaje

If op = "%" Then

TextBox1.Text = num1 * (num2 / 100)

End If

End If

End Sub

Private Sub CommandButton17_Click()

' boton C limpiar todos los valores de las variables y el cuadro de texto

TextBox1.Text = "" ' limpia el cuadro de texto

TextBox1.SetFocus ' configura el cursor en el primer espacio

op = 0 ' configura la variable como cero

num1 = 0 ' configura la variable como cero


num2 = 0 ' configura la variable como cero

End Sub

Private Sub CommandButton18_Click()

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto

op = "R" ' asigna a la variable op el texto "R"

TextBox1.SetFocus ' configura el cursor en el primer espacio

End Sub

Private Sub CommandButton19_Click()

num1 = TextBox1.Text ' asigna el valor del cuadro de texto a la variable num1

TextBox1.Text = "" ' limpia el cuadro de texto

op = "ex" ' asigna a la variable op el texto "ex"

TextBox1.SetFocus ' configura el cursor en el primer espacio

End Sub

Private Sub CommandButton2_Click()

' boton para el ingreso del numero 2 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 2

End Sub

Private Sub CommandButton20_Click()

' boton para el calculo de valor absoluto (calcula el valor absoluto del nuero que esta en el cuadro de
texto)

num1 = TextBox1.Text

TextBox1.Text = Math.Abs(num1)

End Sub

Private Sub CommandButton21_Click()


' boton para el ingreso de número decimal

TextBox1.Text = TextBox1.Text & ","

End Sub

Private Sub CommandButton3_Click()

' boton para el ingreso del numero 3 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 3

End Sub

Private Sub CommandButton4_Click()

' boton para el ingreso del numero 4 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 4

End Sub

Private Sub CommandButton5_Click()

' boton para el ingreso del numero 5 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 5

End Sub

Private Sub CommandButton6_Click()

' boton para el ingreso del numero 6 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 6

End Sub

Private Sub CommandButton7_Click()

' boton para el ingreso del numero 7 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 7

End Sub
Private Sub CommandButton8_Click()

' boton para el ingreso del numero 8 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 8

End Sub

Private Sub CommandButton9_Click()

' boton para el ingreso del numero 9 en el cuadro de texto

TextBox1.Text = TextBox1.Text & 9

End Sub

Private Sub Label1_Click()

End Sub

Private Sub TextBox1_Change()

End Sub

DIAGRAMA DE FLUJO
Inicio

Ingresar primer Número

Elegir operación

Ingresar segundo Número

= resultado

Fin

BIBLIOGRAFIA

Garrido Carrillo, A. (2016). Fundamentos de programación

También podría gustarte