Programación General > Visual Basic 6.0 e inferiores
vb consultar archivo secuencial por fecha
(1/1)
truo:
Hola soy Truo
El codigo que tengo hasta ahora me guarda los datos correctamente, pero no se como se hace un resumen de la venta de un dia con fecha, por ejemplo introduciendo una fecha 13\03\2015 que salga el resumen de dicho dia.
--- Código: ---
Dim fecha As date
Dim nombre As String
Dim apellido As String
Dim producto As String
Dim cantidad As Integer
Dim precio As Integer
Dim total As Integer
Dim archivo As String
Private Sub Command1_Click()
'nuevo
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text2.SetFocus
End Sub
Private Sub Command2_Click()
' guarda los datos
fecha = Text1.Text
nombre = Text2.Text
apellido = Text3.Text
producto = Text4.Text
cantidad = Text5.Text
precio = Text6.Text
total = Val(Text5.Text) * Val(Text6.Text)
archivo = App.Path & "\ventas.txt"
Open archivo For Append As #1
Write #1, fecha, nombre, apellido, producto, cantidad, precio, total
Close #1
End Sub
Private Sub Form_Load()
Text1.Text = Date
End Sub
--- Fin del código ---
Gracias
Haggen:
y cual es la estructura de tu archivo txt (que hace la función de la base de datos)?
Yetis:
Porque no utilizas este sistema?
--- Código: ---Dim fecha As Date
Dim nombre As String
Dim apellido As String
Dim producto As String
Dim cantidad As Integer
Dim precio As Integer
Dim total As Integer
Dim archivo As String
Private mcIni As clsIni
Dim INI_PATH As String
Dim sSeccion As String
Private Sub Command1_Click()
'nuevo
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text2.SetFocus
End Sub
Private Sub Command2_Click()
' guarda los datos
sSeccion = Text1.Text
INI_PATH = App.Path & "\Ventas.ini"
With mcIni
Call .writeValue(INI_PATH, sSeccion, "Fecha", Text1.Text)
Call .writeValue(INI_PATH, sSeccion, "nombre", Text2.Text)
Call .writeValue(INI_PATH, sSeccion, "apellido", Text3.Text)
Call .writeValue(INI_PATH, sSeccion, "producto", Text4.Text)
Call .writeValue(INI_PATH, sSeccion, "cantidad", Text5.Text)
Call .writeValue(INI_PATH, sSeccion, "precio", Text6.Text)
total = Val(Text5.Text) * Val(Text6.Text)
Call .writeValue(INI_PATH, sSeccion, "total", total)
End With
End Sub
Private Sub Command3_Click()
' Recuperar los datos
sSeccion = Text1.Text
INI_PATH = App.Path & "\Ventas.ini"
Text1 = mcIni.getValue(INI_PATH, sSeccion, "Fecha")
Text2 = mcIni.getValue(INI_PATH, sSeccion, "nombre")
Text3 = mcIni.getValue(INI_PATH, sSeccion, "apellido")
Text4 = mcIni.getValue(INI_PATH, sSeccion, "producto")
Text5 = mcIni.getValue(INI_PATH, sSeccion, "cantidad")
Text6 = mcIni.getValue(INI_PATH, sSeccion, "precio")
End Sub
Private Sub Form_Load()
Set mcIni = New clsIni
Text1.Text = Date
End Sub
--- Fin del código ---
Navegación
Ir a la versión completa