
Curso Básico de Programación en Visual Basic
Visual Basic
Publicado el 13 de Mayo del 2002 por Administrador
56.973 visualizaciones desde el 13 de Mayo del 2002
Curso de Visual Basic por entregas. Muy interesante.
Forma parte de El Guille
Si alguno de los archivos de descarga no funciona, comentanos aquí el error.
Comentarios... (16)
Sólo quiero comentar que eres una persona muy agradable, el manual de visual basic me ha servido bastante como guia. Soy estudiante de ingenieria en Sistemas Computacionales y no he tenido un buen maestro que me sepa explicar como usar el visual basic... De verdad que te felicito porque has sabido aclararme varias dudas que yo tenia.
Gracias..
en este formulario y anticipadamente te quiro dar la gracias por la ayuda que le das a todos los estudiantes que se estan iniciando en mundo visual
Public seguir As Integer
Option Explicit
Private tbase1 As ADODB.Connection
Private WithEvents ttcliente As ADODB.Recordset
Attribute ttcliente.VB_VarHelpID = -1
Private Sub cancelar_Click()
Form_Initialize
salir.SetFocus
End Sub
Private Sub eliminar_Click()
Dim ttcliente As Recordset
If MsgBox("Esta Seguro De Eliminar El Registro Actual", vbYesNo) = vbYes Then
With ttcliente
If (.EOF Or .BOF) Then
MsgBox ("No Hay Ningun Registro Activo")
Else
.Delete
.MoveFirst
cancelar_Click
End If
End With
Else
MsgBox ("Eliminacion Abortada")
End If
End Sub
Private Sub Form_Load()
Const spathbase As String = "C:\Mis documentos\visual basic\FGSYSTEM\base1.mdb"
Set tbase1 = New ADODB.Connection
Set ttcliente = New ADODB.Recordset
With tbase1
.ConnectionString = _
"provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=" & spathbase & ";"
.Open
End With
End Sub
Private Sub Form_Initialize()
txtcodigo.Text = ""
txtnombres.Text = ""
txtapellidos.Text = ""
txtcedula.Text = ""
txtcorreo.Text = ""
txtfecha.Text = ""
txtocupacion.Text = ""
Txttelefono.Text = ""
txtdireccion.Text = ""
Deshabilitar_txt
txtcodigo.Enabled = True
deshabilitar_botones
End Sub
Sub habilitar_txt()
txtcodigo.Enabled = True
txtnombres.Enabled = True
txtapellidos.Enabled = True
txtcedula.Enabled = True
txtcorreo.Enabled = True
txtfecha.Enabled = True
txtocupacion.Enabled = True
Txttelefono.Enabled = True
txtdireccion.Enabled = True
End Sub
Sub Deshabilitar_txt()
txtcodigo.Enabled = False
txtnombres.Enabled = False
txtapellidos.Enabled = False
txtcedula.Enabled = False
txtcorreo.Enabled = False
txtfecha.Enabled = False
txtocupacion.Enabled = False
Txttelefono.Enabled = False
txtdireccion.Enabled = False
End Sub
Sub mostrar()
txtcodigo.Text = ttcliente.Fields("codigo")
txtnombres.Text = ttcliente.Fields("nombres")
txtcedula.Text = ttcliente.Fields("cedula")
txtdireccion.Text = ttcliente.Fields("direccion")
txtocupacion.Text = ttcliente.Fields("ocupacion")
txtcorreo.Text = ttcliente.Fields("correo")
txtfecha.Text = ttcliente.Fields("fecha")
txtapellidos.Text = ttcliente.Fields("apellidos")
Txttelefono.Text = ttcliente.Fields("telefono")
End Sub
Public Sub añadir()
ttcliente.Fields("codigo") = txtcodigo.Text
ttcliente.Fields("nombres") = txtnombres.Text
ttcliente.Fields("cedula") = txtcedula.Text
ttcliente.Fields("direccion") = txtdireccion.Text
ttcliente.Fields("ocupacion") = txtocupacion.Text
ttcliente.Fields("correo") = txtcorreo.Text
ttcliente.Fields("fecha") = txtfecha.Text
ttcliente.Fields("apellidos") = txtapellidos.Text
ttcliente.Fields("telefono") = Txttelefono.Text
End Sub
Private Sub incluir_Click()
deshabilitar_botones
cancelar.Enabled = True
añadir
ttcliente.Update
ttcliente.MoveLast
MsgBox ("Registro Satisfactorio")
cancelar_Click
End Sub
Private Sub modificar_Click()
habilitar_txt
deshabilitar_botones
cancelar.Enabled = True
incluir.Enabled = False
txtcodigo.Enabled = False
modificar.Enabled = True
modificar.Caption = "Actualizar"
If seguir = 2 Then
modificar.Caption = "Modificar"
añadir
ttcliente.MoveFirst
ttcliente.Update
MsgBox ("Actualizacion Satisfactoria")
cancelar_Click
End If
seguir = seguir + 1
End Sub
Private Sub salir_Click()
Unload Me
End Sub
Public Sub deshabilitar_botones()
incluir.Enabled = False
modificar.Enabled = False
eliminar.Enabled = False
cancelar.Enabled = False
End Sub
Public Sub habilitar_botones()
incluir.Enabled = True
modificar.Enabled = True
eliminar.Enabled = True
cancelar.Enabled = True
End Sub
Private Sub txtcodigo_LostFocus()
Dim sbuscar As String
sbuscar = txtcodigo.Text
sbuscar = Replace(sbuscar, "*", "%")
sbuscar = Replace(sbuscar, "?", "_")
txtcodigo.Text = sbuscar
sbuscar = "select * from tcliente where codigo like '" & sbuscar & "' order by codigo"
Set ttcliente = tbase1.Execute(sbuscar)
With ttcliente
If (.BOF And .EOF) Then
If MsgBox(" El Cliente No 'EXISTE' ¿Desea Registrarlo? ", vbYesNo) = vbYes Then
.AddNew
habilitar_txt
txtcodigo.Enabled = False
habilitar_botones
modificar.Enabled = False
eliminar.Enabled = False
End If
Else
Do While Not .EOF
seguir = 1
Deshabilitar_txt
mostrar
habilitar_botones
incluir.Enabled = False
.MoveNext
Loop
End If
End With
End Sub
espero que me puedas ayudar a solventar este problema ya que me ha tenido bastante preocupado al no saber como resolverlo
gracias
espero que puedas responderme guille gracias
en este formulario y anticipadamente te quiro dar la gracias por la ayuda que le das a todos los estudiantes que se estan iniciando en mundo visual
Public seguir As Integer
Option Explicit
Private tbase1 As ADODB.Connection
Private WithEvents ttcliente As ADODB.Recordset
Attribute ttcliente.VB_VarHelpID = -1
Private Sub cancelar_Click()
Form_Initialize
salir.SetFocus
End Sub
Private Sub eliminar_Click()
Dim ttcliente As Recordset
If MsgBox("Esta Seguro De Eliminar El Registro Actual", vbYesNo) = vbYes Then
With ttcliente
If (.EOF Or .BOF) Then
MsgBox ("No Hay Ningun Registro Activo")
Else
.Delete "aqui tambien"
.MoveFirst
cancelar_Click
End If
End With
Else
MsgBox ("Eliminacion Abortada")
End If
End Sub
Private Sub Form_Load()
Const spathbase As String = "C:\Mis documentos\visual basic\FGSYSTEM\base1.mdb"
Set tbase1 = New ADODB.Connection
Set ttcliente = New ADODB.Recordset
With tbase1
.ConnectionString = _
"provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=" & spathbase & ";"
.Open
End With
End Sub
Private Sub Form_Initialize()
txtcodigo.Text = ""
txtnombres.Text = ""
txtapellidos.Text = ""
txtcedula.Text = ""
txtcorreo.Text = ""
txtfecha.Text = ""
txtocupacion.Text = ""
Txttelefono.Text = ""
txtdireccion.Text = ""
Deshabilitar_txt
txtcodigo.Enabled = True
deshabilitar_botones
End Sub
Sub habilitar_txt()
txtcodigo.Enabled = True
txtnombres.Enabled = True
txtapellidos.Enabled = True
txtcedula.Enabled = True
txtcorreo.Enabled = True
txtfecha.Enabled = True
txtocupacion.Enabled = True
Txttelefono.Enabled = True
txtdireccion.Enabled = True
End Sub
Sub Deshabilitar_txt()
txtcodigo.Enabled = False
txtnombres.Enabled = False
txtapellidos.Enabled = False
txtcedula.Enabled = False
txtcorreo.Enabled = False
txtfecha.Enabled = False
txtocupacion.Enabled = False
Txttelefono.Enabled = False
txtdireccion.Enabled = False
End Sub
Sub mostrar()
txtcodigo.Text = ttcliente.Fields("codigo") "aqui me da el error"
txtnombres.Text = ttcliente.Fields("nombres")
txtcedula.Text = ttcliente.Fields("cedula")
txtdireccion.Text = ttcliente.Fields("direccion")
txtocupacion.Text = ttcliente.Fields("ocupacion")
txtcorreo.Text = ttcliente.Fields("correo")
txtfecha.Text = ttcliente.Fields("fecha")
txtapellidos.Text = ttcliente.Fields("apellidos")
Txttelefono.Text = ttcliente.Fields("telefono")
End Sub
Public Sub añadir()
ttcliente.Fields("codigo") = txtcodigo.Text "aqui ta,bien"
ttcliente.Fields("nombres") = txtnombres.Text
ttcliente.Fields("cedula") = txtcedula.Text
ttcliente.Fields("direccion") = txtdireccion.Text
ttcliente.Fields("ocupacion") = txtocupacion.Text
ttcliente.Fields("correo") = txtcorreo.Text
ttcliente.Fields("fecha") = txtfecha.Text
ttcliente.Fields("apellidos") = txtapellidos.Text
ttcliente.Fields("telefono") = Txttelefono.Text
End Sub
Private Sub incluir_Click()
deshabilitar_botones
cancelar.Enabled = True
añadir
ttcliente.Update "aqui tambien"
ttcliente.MoveLast
MsgBox ("Registro Satisfactorio")
cancelar_Click
End Sub
Private Sub modificar_Click()
habilitar_txt
deshabilitar_botones
cancelar.Enabled = True
incluir.Enabled = False
txtcodigo.Enabled = False
modificar.Enabled = True
modificar.Caption = "Actualizar"
If seguir = 2 Then
modificar.Caption = "Modificar"
añadir
ttcliente.MoveFirst
ttcliente.Update "aqui tambien"
MsgBox ("Actualizacion Satisfactoria")
cancelar_Click
End If
seguir = seguir + 1
End Sub
Private Sub salir_Click()
Unload Me
End Sub
Public Sub deshabilitar_botones()
incluir.Enabled = False
modificar.Enabled = False
eliminar.Enabled = False
cancelar.Enabled = False
End Sub
Public Sub habilitar_botones()
incluir.Enabled = True
modificar.Enabled = True
eliminar.Enabled = True
cancelar.Enabled = True
End Sub
Private Sub txtcodigo_LostFocus()
Dim sbuscar As String
sbuscar = txtcodigo.Text
sbuscar = Replace(sbuscar, "*", "%")
sbuscar = Replace(sbuscar, "?", "_")
txtcodigo.Text = sbuscar
sbuscar = "select * from tcliente where codigo like '" & sbuscar & "' order by codigo"
Set ttcliente = tbase1.Execute(sbuscar)
With ttcliente
If (.BOF And .EOF) Then
If MsgBox(" El Cliente No 'EXISTE' ¿Desea Registrarlo? ", vbYesNo) = vbYes Then
.AddNew
habilitar_txt
txtcodigo.Enabled = False
habilitar_botones
modificar.Enabled = False
eliminar.Enabled = False
End If
Else
Do While Not .EOF
seguir = 1
Deshabilitar_txt
mostrar
habilitar_botones
incluir.Enabled = False
.MoveNext
Loop
End If
End With
End Sub
espero que me puedas ayudar a solventar este problema ya que me ha tenido bastante preocupado al no saber como resolverlo
gracias
espero que puedas responderme guille gracias
···NO LOS PUEDO BAJAR·····
POR FAVOR
Salu2.
¡¡¡Erico!!!
Salu2.
¡¡¡Erico!!!
Esto está ideal para una persona nueva en programación y sin experiencia
Gracias