Primer Paso: ingresar a Visual Basic 6.0 Dentro de Visual basic Crear un formulario que se llame " ficha " ( sin comillas ) acá les dejo el link de la imagen http://img53.xooimage.com/files/a/e/f/ficha-230fbd0.png lo que se ve en azul son las etiquetas o label y los recuadros en blanco se llaman textbox o cuadros de textos, estos tienen un nombre en particular cada uno ya que van a ser importantes a la hora de codificar, los nombres de los textboxs son los siguientes matricula_txt apellido_txt nombre_txt nota1_txt nota2_txt nota3_txt y el ultimo es una etiqueta que se llama promedio_lbl, la siguiente es una etiqueta porque de ser un textbox el contenido podria ser modificado, para que parezca un textbox tenemos que hacer unos cambios en las propiedades, *la propiedad appeareance = 1-3D *Border Style = Fixed Single *Back Color = seleccionamos el blanco en la paleta. Dentro del formulario se encuentran tres botones, los mismos se llaman *siguiente_btn *listado_btn *salir_btn. Luego agregamos otro formulario desde el administrador de proyectos que se llame " listado" el mismo se ve asi http://img52.xooimage.com/files/5/b/7/listado-230fc7b.png como antes lo que esta en azul son etiquetas, pero ahora lo que parecen textbox se llaman listbox, los mismos se llaman asi: matricula_lis apellido_lis nombre_lis nota1_lis nota2_lis nota3_lis promedio_lis ( como en el formulario anterior es importante los nombres de los controles, por su codificación) !!AHORA LA CODIFICACION !! codigo del formulario " ficha " Private Sub apellido_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If apellido_txt.Text <> "" Then nombre_txt.SetFocus End If End If End Sub Private Sub Form_Load() contador = 0 End Sub Private Sub listado_btn_Click() Unload ficha listado.Show 1 End Sub Private Sub matricula_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(matricula_txt.Text) = True Then If Val(matricula_txt.Text) >= 1 And Val(matricula_txt.Text) <= 1000 Then apellido_txt.SetFocus End If End If End If End Sub Private Sub nombre_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If apellido_txt.Text <> "" Then nota1_txt.SetFocus End If End If End Sub Private Sub nota1_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(nota1_txt.Text) = True Then If Val(nota1_txt.Text) >= 1 And Val(nota1_txt.Text) <= 10 Then nota2_txt.SetFocus End If End If End If End Sub Private Sub nota2_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(nota2_txt.Text) = True Then If Val(nota2_txt.Text) >= 1 And Val(nota2_txt.Text) <= 10 Then nota3_txt.SetFocus End If End If End If End Sub Private Sub nota3_txt_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(nota3_txt.Text) = True Then If Val(nota3_txt.Text) >= 1 And Val(nota3_txt.Text) <= 10 Then prom = (Val(nota1_txt.Text) + Val(nota2_txt.Text) + Val(nota3_txt.Text)) / 3 promedio_lbl.Caption = prom siguiente_btn.SetFocus End If End If End If End Sub Private Sub salir_btn_Click() Unload Me End Sub Private Sub siguiente_btn_Click() matricula(contador) = matricula_txt.Text apellido(contador) = apellido_txt.Text nombre(contador) = nombre_txt.Text nota1(contador) = nota1_txt.Text nota2(contador) = nota2_txt.Text nota3(contador) = nota3_txt.Text promedio(contador) = promedio_lbl.Caption contador = contador + 1 If contador = 100 Then Call Desactivar listado_btn.SetFocus Else Call Limpiar matricula_txt.SetFocus End If End Sub Private Sub Desactivar() matricula_txt.Enabled = False apellido_txt.Enabled = False nombre_txt.Enabled = False nota1_txt.Enabled = False nota2_txt.Enabled = False nota3_txt.Enabled = False promedio_lbl.Enabled = False siguiente_btn.Enabled = False End Sub Private Sub Limpiar() matricula_txt.Text = "" apellido_txt.Text = "" nombre_txt.Text = "" nota1_txt.Text = "" nota2_txt.Text = "" nota3_txt.Text = "" promedio_lbl.Caption = "" End Sub -------------------------------------------------------------------------- Codigo de "listado" Private Sub Form_Load() For x = 0 To contador matricula_lis.AddItem matricula(x) apellido_lis.AddItem apellido(x) nombre_lis.AddItem nombre(x) nota1_lis.AddItem nota1(x) nota2_lis.AddItem nota2(x) nota3_lis.AddItem nota3(x) promedio_lis.AddItem promedio(x) Next x End Sub Private Sub salir_btn_Click() Unload Me End Sub ------------------------------------------------------ Ahora lo último que tendriamos que hacer es agregar un Módulo, el mismo se agrega desde administrador de proyectos. y la codificación es la siguiente: Public matricula(100) Public apellido(100) Public nombre(100) Public nota1(100) Public nota2(100) Public nota3(100) Public promedio(100) Public contador As Integer Public x As Integer ----------------------------------------------------------------------- ( en el modulo lo que declaramos fueron las variables de tipo Public, que serán utilizadas en los dos formularios) con esto finalizamos nuestro programita
Programita sencillo en Visual Basic 6.0
Datos archivados del Taringa! original
15puntos
5,938visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
2visitas
0comentarios
Dar puntos: