Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

EJEMPLOS DE VISUAL BASIC

DANIEL FELIPE ARIAS BLANCO JAVIER ANDRES GARCIA GUTERREZ

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

DANIEL FELIPE ARIAS BLANCO JAVIER ANDRES GARCIA GUTIERREZ

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 que uno puede seleccionar el color que quiera y este se va ha mostrar en pantalla ya sea arriba o abajo

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 = 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 5

Private Sub cmdSalir_Click() Beep End End Sub 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) 6

Text4.Text = suma End Sub Private Sub Command3_Click() End

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") 7

Text3.SetFocus Else Text4.Text = suma End If End If 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 8

End Sub Private Sub Label4_Click() 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 9

End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) Dim aut As Double If KeyAscii = 13 Then 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

You might also like