Está en la página 1de 10

EJEMPLOS DE VISUAL BASIC

OMAR DAVID ANGULO MORENO WEIMAR ALDEMAR GOMEZ LOPEZ JAVIER DAVID PUENTES VELASCO

INSTITUTO EDUCATIVO ANTONIO NARIO SEDE TECNICA LOGICA Y PROGRAMACION 10-01 TECNICO MONIQUIRA 2011

OMAR DAVID ANGULO MORENO WEIMAR ALDEMAR GOMEZ LOPEZ JAVIER DAVID PUENTES VELASCO

INSTITUTO EDUCATIVO ANTONIO NARIO SEDE TECNICA LOGICA Y PROGRAMACION 10-01 TECNICO MONIQUIRA 2011

Tabla de contenido
1. 2. 3. 4. EJEMPLO DE COLORES................................................................................................................. 4 EJEMPLO DE TEMPERATURA5 EJEMPLO DE SUMAS.6 EJEMPLO DE NOTAS.8

1. EJEMPLO DE COLORES Trata de selecciona el color que se quiera mostrar en el leigo y tambien la posicion o la ubicacin donde quieran el leigo.

Private Sub Form_Load() End Sub Private Sub Option1_Click() Text1.BackColor = vbBlue End Sub Private Sub Option2_Click() Text1.BackColor = vbRed End Sub Private Sub Option3_Click() Text1.BackColor = vbGreen End Sub Private Sub Option4_Click() Text1.BackColor = vbYellow End Sub Private Sub Option5_Click() Text1.Top = 4

End Sub Private Sub Option6_Click() Text1.Top = From1.ScaleHeight - Text1.Height End Sub

2.EJEMPLO DE TEMPERATURA: permite ver la equivalencia entre las escalas de

temperaturas en grados centgrados y grados Fahrenheit.

Private Sub Command1_Click() Beep End End Sub Private Sub Text3_Change() End Sub Private Sub mnuFile_Click() End End Sub Private Sub cmdSalir_Click() Beep End End Sub 5

Private Sub Form_Load() End Sub Private Sub VScroll1_Change() TextCent.Text = VScroll1.Value TextFahr.Text = 32 + 1.8 * VScroll1.Value End Sub 3. EJEMPLO DE SUMAS: consiste en una aplicacin que suma distintas sifras dada la operacin suma.

Private Sub Command1_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" End Sub Private Sub Command2_Click() Dim suma As Integer suma = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) Text4.Text = suma End Sub Private Sub Command3_Click() End 6

End Sub Private Sub Form_Load() End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text1.Text = "" Then MsgBox ("digite un numero") Text1.SetFocus Else Text2.SetFocus End If End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text2.Text = "" Then MsgBox ("digite un numero") Text2.SetFocus Else Text3.SetFocus End If End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text3.Text = "" Then MsgBox ("digite un numero") Text3.SetFocus Else Text4.Text = suma End If End If 7

End Sub 4. EJEMPLO DE NOTAS: consiste en una aplicacin que computa todas las notas y como resultado da la nota final o definitiva del periodo.

Private Sub Command1_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" End Sub Private Sub Command2_Click() Dim suma As Double suma = (((Val(Text1.Text) * 0.5)) + ((Val(Text2.Text) * 0.2)) + ((Val(Text3.Text) * 0.15)) + ((Val(Text4.Text) * 0.15))) Text5.Text = suma End Sub Private Sub Command3_Click() End

End Sub Private Sub Label4_Click() 8

End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim cog As Double If KeyAscii = 13 Then cog = Text1.Text If Text1 = "" Then MsgBox ("digite un numero") Text1.SetFocus ElseIf cog < 1 Or cog > 5 Then MsgBox ("el valor no es permitido") Text1.SetFocus Else Text2.SetFocus End If End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) Dim pro As Double If KeyAscii = 13 Then pro = Text2.Text If Text2 = "" Then MsgBox ("digite un numero") Text2.SetFocus ElseIf pro < 1 Or cog > 5 Then MsgBox ("el valor no es permitido") Text2.SetFocus Else Text3.SetFocus End If End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) Dim aut As Double If KeyAscii = 13 Then 9

aut = Text3.Text If Text3 = "" Then MsgBox ("digite un numero") Text3.SetFocus ElseIf aut < 1 Or cog > 5 Then MsgBox ("el valor no es permitido") Text3.SetFocus Else Text4.SetFocus End If End If End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) Dim act As Double If KeyAscii = 13 Then act = Text4.Text If Text4 = "" Then MsgBox ("digite un numero") Text4.SetFocus ElseIf act < 1 Or cog > 5 Then MsgBox ("el valor no es permitido") Text4.SetFocus Else Text5.SetFocus End If End If End Sub

10

También podría gustarte