Ver Mensaje Individual
  #9 (permalink)  
Antiguo 12/06/2009, 10:30
newnovato
 
Fecha de Ingreso: marzo-2009
Mensajes: 117
Antigüedad: 15 años, 2 meses
Puntos: 2
Respuesta: ayudar con visual basic 6.0

amigo ya agrege el vsflexarray

este codigo lo coloco en que boton? xq entiendo los otros y se donde van pero no se donde agregar este codigo

Crea un módulo y pon el siguiente código:
Sub Rotulo(vsFxAy As vsFlexArray)
With vsFxAy
.Cols = 3
.RowHeight(0) = 450
.ColWidth(0) = 280
.TextArray(1) = "ID"
.ColWidth(1) = 600
.TextArray(2) = "Nombre"
.ColWidth(2) = 3000
End With
End Sub


Sub CargarDatos(vsFxAy As vsFlexArray)
Dim BDCn As New ADODB.Connection
Dim BDRd As New ADODB.Recordset
Dim Tabla As String
Dim Ruta As String
Ruta = App.Path & "\" & "db1.mdb"
BDCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Ruta & ";Persist Security Info=False"
Tabla = "Nombres"
BDRd.Open Tabla, BDCn, adOpenStatic, adLockReadOnly
With vsFxAy
vsFxAy.Rows = 2
Do While Not BDRd.EOF
.TextMatrix(vsFxAy.Rows - 1, 1) = BDRd.Fields(0).Value
.TextMatrix(vsFxAy.Rows - 1, 2) = BDRd.Fields(1).Value
vsFxAy.Rows = vsFxAy.Rows + 1
BDRd.MoveNext
Loop
.Rows = .Rows - 1
End With
BDRd.Close
BDCn.Close
End Sub

Sub AgregarDatos(ID As String, Nombre As String)
Dim BDCn As New ADODB.Connection
Dim BDRd As New ADODB.Recordset
Dim Tabla As String
Dim Ruta As String
Dim Cursor As String
Dim Cerrojo As String
Cursor = 1
Cerrojo = 3
Ruta = App.Path & "\" & "db1.mdb"
BDCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Ruta & ";Persist Security Info=False"
Tabla = "Nombres"
BDRd.Open Tabla, BDCn, Cursor, Cerrojo
If Not BDRd.BOF Then
BDRd.AddNew
BDRd("ID") = ID
BDRd("Nombre") = Nombre
BDRd.Update
End If
BDRd.Close
BDCn.Close
End Sub



xq estos comandos son los de los coman boton

Private Sub Command1_Click()
Call AgregarDatos(Text1.Text, Text2.Text)
Call CargarDatos(vsFlexArray1)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Call CargarDatos(vsFlexArray1)
End Sub


y este es el comando del formulario:

Luego en el formulario pega estas lineas de código:
Private Sub Form_Load()
Call Rotulo(vsFlexArray1)
End Sub
Private Sub Command1_Click()
Call AgregarDatos(Text1.Text, Text2.Text)
Call CargarDatos(vsFlexArray1)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub