Ejercicios Vb
Prof.: Lic. Toledo Marcelo Alejandro
e-mail: mtoledo@dgrfsa.gov.ar
Ejercicio 1
Dim saludo As String * 10
Private Sub Command1_Click()
Dim Nombre As String * 10
Nombre = "Joaquim"
saludo = "HOLA"
Print saludo; y; Nombre
End Sub
Private Sub Command2_Click()
saludo = "ADIOS"
Print saludo
End Sub
Ejercicio 2
1
Ejercicios de Visual Basic
Prof.:Lic. Toledo Marcelo Alejandro
e-mail: mtoledo@dgrfsa.gov.ar
Private Sub Boton_dividir_Click()
Dim result As Integer
result = Val(Numero_uno.Text) / Val(Numero_dos.Text)
Numero_resultado.Text = Str(result)
End Sub
Private Sub Boton_multiplicar_Click()
Dim result As Integer
result = Val(Numero_uno.Text) * Val(Numero_dos.Text)
Numero_resultado.Text = Str(result)
End Sub
Private SubBoton_restar_Click()
Dim result As Integer
result = Val(Numero_uno.Text) - Val(Numero_dos.Text)
Numero_resultado.Text = Str(result)
End Sub
Private Sub Boton_salir_Click()
End
End Sub
Private Sub Boton_Sumar_Click()
Dim result As Integer
result = Val(Numero_uno.Text) + Val(Numero_dos.Text)
Numero_resultado.Text = Str(result)
End Sub
Ejercicio 3
2
Ejercicios de Visual BasicProf.: Lic. Toledo Marcelo Alejandro
e-mail: mtoledo@dgrfsa.gov.ar
Private Sub Command1_Click()
Dim result, resulta As Double
result = Val(Text1.Text) * (60)
Text2.Text = Str(result)
resulta = Val(Text2.Text) * (60)
Text3.Text = Str(resulta)
End Sub
Private Sub Command2_Click()
End
End Sub
Ejercicio 4
Private Sub Azul_Click()
Texto.ForeColor = &HFF0000
End Sub
Private SubCommand1_Click()
End
End Sub
Private Sub Cursiva_Click()
Texto.FontItalic = True
Texto.FontBold = False
End Sub
Private Sub Form_Load()
Normal.Value = True
Azul.Value = True
Texto.FontBold = False
Texto.FontItalic = False
Texto.ForeColor = &HFF0000
End Sub
3
Ejercicios de Visual Basic
Prof.: Lic. Toledo Marcelo Alejandro
e-mail: mtoledo@dgrfsa.gov.ar
Private Sub Negrilla_Click()Texto.FontBold = True
Texto.FontItalic = False
End Sub
Private Sub Normal_Click()
Texto.FontBold = False
Texto.FontItalic = False
End Sub
Private Sub Verde_Click()
Texto.ForeColor = &HFF00&
End Sub
Ejercicio 5
Private Sub Ape_GotFocus()
Ape.SelStart = 0
Ape.SelLength = Len(Ape.Text)
End Sub
Private Sub Boton_añadir_Click()
totalregistros = totalregistros + 1
If totalregistros >50 Then
MsgBox "losta completa", 16, "error"
Else
agenda(totalregistros).Nombre = Nom.Text
agenda(totalregistros).apellidos = Ape.Text
agenda(totalregistros).telefono = Tel.Text
agenda(totalregistros).Edad = Val(Edad.Text)
Lista_1.AddItem Nom.Text
Lista_2.AddItem Nom.Text
End If
Nom.SetFocus
End Sub
4
Ejercicios de Visual Basic
Prof.: Lic. Toledo Marcelo Alejandro
e-mail:mtoledo@dgrfsa.gov.ar
Private Sub Boton_eliminar_Click(Index As Integer)
Dim I, B As Integer
For I = 1 To totalregistros
If (RTrim$(Lista_1.Text) = RTrim$(agenda(I).Nombre)) Then
Exit For
End If
Next I
Nom.Text = agenda(I).Nombre
Ape.Text = agenda(I).apellidos
Tel.Text = agenda(I).telefono
Edad.Text = Str(agenda(I).Edad)
B = MsgBox("Eliminar Registro:" + Nom.Text, 3 + 32, "Eliminar")
If B= 6 Then
Lista_1.RemoveItem I - 1
totalregistros = totalregistros - 1
For j = I To totalregistros
agenda(j).Nombre = agenda(j + 1).Nombre
agenda(j).apellidos = agenda(j + 1).apellidos
agenda(j).telefono = agenda(j + 1).telefono
agenda(j).Edad = agenda(j + 1).Edad
Next j
Nom.Text = ""
Ape.Text = ""
Tel.Text = ""
Edad.Text = ""
End If
End Sub
Private Sub Boton_fin_Click(Index AsInteger)
End
End Sub
Private Sub Eda_GotFocus()
Eda.SelStart = 0
Eda.SelLength = Len(Eda.Text)
End Sub
Private Sub Form_Load()
totalregistros = 0
End Sub
Private Sub Lista_2_Change()
Dim n As Integer
n = Lista_2.ListIndex + 1
Nom.Text = agenda(n).Nombre
Ape.Text = agenda(n).apellidos
Tel.Text = agenda(n).telefono
Eda.Text = agenda(n).Edad
End Sub
5
Ejercicios de Visual Basic...
Regístrate para leer el documento completo.