etiquetas, cajas de textos y botón private sub pulsa_click() r = val(text1.text) l = 2 * 3.1416 * r...

16

Upload: celia-casado-miguelez

Post on 24-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 2: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Etiquetas, Cajas de textos y botón

Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End Sub

Page 3: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Private Sub CmdAceptar_Click()Dim N1 As Double, N2 As Double, N3 As Double Dim Promedio As Integer N1 = Val(TxtN1): N2 = Val(TxtN2)

N3 = Val(TxtN3) Promedio = CInt((N1 + N2 + N3) / 3) TxtPromedio = Str(Promedio)End Sub

Private Sub CmdLimpiar_Click()TxtAlumno = ""TxtN1 = ""TxtN2 = ""TxtN3 = ""TxtPromedio = ""End Sub

Private Sub CmdSalir_Click()EndEnd Sub

Ejercicio: PROMEDIO

Page 4: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 5: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 6: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 7: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 8: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Frames, Etiquetas, Cajas de textos y

Botón.

Private Sub Calcula_Click() C = Val(Text1.Text) i = Val(Text2.Text) / 100 a = Val(Text3.Text) T = C * (1 + i) ^ a Text4.Text = T End Sub

Page 9: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Programa: Área de un triángulo:

Con este programa se calcula el área de un triángulo, los datos pedidos son la Base y la Altura.

Page 10: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

 Option Explicit

 Private Sub cmdBorrar_Click()

txtBase = "“

txtAltura = ""

txtResultado = ""

cmdCalcular.Enabled = False

txtBase.SetFocus

End Sub

  

 Private Sub cmdCalcular_Click()

Dim Base As Double, Altura As Double, Area As Double

Base = Val(txtBase)

Altura = Val(txtAltura)

If IsNumeric(txtBase) And IsNumeric(txtAltura) Then

Area = Base * Altura / 2

txtResultado = Area

Else

MsgBox "No se acepta texto. Verifique para

continuar", vbOKOnly + vbExclamation, "Error"

End If

End Sub

Page 11: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Private Sub txtBase_Change()

If Len(txtBase) > 0 And Len(txtAltura) > 0 Then

cmdCalcular.Enabled = True

End If

End Sub

Private Sub txtBase_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then

txtAltura.SetFocus

End If

End Sub

 Private Sub txtAltura_Change()

If Len(txtBase) > 0 And Len(txtAltura) > 0 Then

cmdCalcular.Enabled = True

End If

End Sub

Page 12: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Private Sub txtAltura_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If cmdCalcular.Enabled = True Then

cmdCalcular.SetFocus

Else

TxtBase.SetFocus

End If

End If

End Sub

Page 13: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End

Controles : Check y Option

Utilizamos 2 Frames. Comidas y Bebidas.- El usuario puede marcar varios Check pero un

solo Option- Podemos elegir varias comidas pero solo una bebida.- Las comidas se van acumulando: com = com & "Carne"- Para que en un Text se puedan poner varias líneas debe tener la Propiedad Multiline en True- Para cambiar de renglón en un Text se utiliza vbCrLf- Cuando en el código una línea es muy larga se puede pasar a otra mediante

Page 14: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 15: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End
Page 16: Etiquetas, Cajas de textos y botón Private Sub Pulsa_Click() r = Val(Text1.Text) l = 2 * 3.1416 * r a = 3.1416 * r * r Text2.Text = l Text3.Text = a End