Hola soy Corlo
muchas gracias Nebire por tu codigo me ha servido de mucha ayuda, muchisimas gracias.
muchas gracias Nebire por tu codigo me ha servido de mucha ayuda, muchisimas gracias.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
Option Explicit
Dim n As Integer
Private Sub Command1_Click()
'Nuevo
Open App.Path & "\database.txt" For Random As 1 Len = Len(file)
n = LOF(1) / Len(file)
Get #1, n, file
Text1.Text = n + 1
Close #1
Text2.Text = Format(date, "dd/mm/yyyy")
Text3.Text = ""
Text3.SetFocus
End Sub
Private Sub Command2_Click()
'Guardar
file.id = Text1.Text
file.date = Text2.Text
file.name = Text3.Text
Open App.Path & "\database.txt" For Random As 1 Len = Len(file)
n = LOF(1) / Len(file)
Put #1, n + 1, file
Close #1
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Unload Me
Form2.Show
End Sub
Private Sub Form_Load()
Open App.Path & "\database.txt" For Random As 1 Len = Len(file)
n = LOF(1) / Len(file)
Get #1, n, file
Text1.Text = n + 1
Close #1
Text2.Text = Format(date, "dd/mm/yyyy")
End Sub
Type Task
id As Integer
date As Date
name As String * 30
End Type
Option Explicit
Global file As Task
en un modulo:
Type Task
id As Integer
date As Date
name As String * 30
End Type
Option Explicit
Global file As Task
en el formulario
Private f_Canal As Integer ' canal del fichero.
Private Sub List1_Click()
Call BuscarItems(lisFechas.List(lisFechas.ListIndex))
End Sub
' Qué buscamos?: El dato (fecha), que se ha pulsado en list1...
' y lo buscamos en todos los registros del fichero.
Private Sub BuscarItems(ByVal strFecha As String)
Dim item As String
List2.Clear
Open App.Path & "\database.txt" For Random As f_canal Len = Len(file)
Seek (f_Canal), 1 ' posicionar el puntero de lectura al comienzo del fichero (en vb6 es la dirección 1).
Do While Not EOF(f_Canal)
Get f_Canal, , file
With file
If (StrComp(strFecha, CStr(.Date), vbTextCompare) = 0) Then
item = FormatStr(CStr(.Id), 6, True)
item = FormatStr(item, 12) & _
FormatStr(CStr(.Date), 16) & _
FormatStr(.Name, 44)
Call List2.AddItem(item) ' list2, probablemente no precise estar ordenado...
End If
End With
Loop
Close #f_canal
End Sub
Option Explicit
Dim n As Integer
Dim c As Integer
Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub
Private Sub Form_Load()
List1.Clear
Open App.Path & "\database.txt" For Random As 1 Len = Len(file)
n = LOF(1) / Len(file)
c = 1
For c = 1 To n
Get #1, , file
List1.AddItem file.date
QuitaDup
Next
Close #1
End Sub
Private Sub QuitaDup()
Dim i As Long, X As Long
X = List1.ListCount - 1
For i = 0 To List1.ListCount - 2
If List1.List(i) = List1.List(X) Then
List1.RemoveItem X
Exit For
End If
Next i
End Sub
Private Sub List1_Click()
Dim i As Integer
Dim ind As Integer
List2.Clear
Form1.Text1.Text = file.id
Form1.Text2.Text = file.date
Form1.Text3.Text = file.name
ind = List1.ListIndex
Open App.Path & "\database.txt" For Random As 1 Len = Len(file)
n = LOF(1) / Len(file)
For i = 0 To List1.ListCount + 1
If ind <= 0 Then
Get #1, i + 1, file
List2.AddItem file.id & " " & file.date & " " & file.name
End If
Next
Close #1
End Sub
Dim i As Integer
mes = Text8.Text
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)
Text7.Text = Val(Text5.Text) * Val(Text6.Text)
archivo = App.Path & "\ventas.txt"
Open archivo For Append As #1
Write #1, mes, fecha, nombre, apellido, producto, cantidad, precio, total
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next i
Close #1
dim d as integer
dim sum as integer
dim gh as string
gh = App.Path & "\facturas" & "\" & Prefix_Facturas & Text3.Text & ".TXT"
Open gh For Random As #1 Len = Len(datos)
Get #1, (List1.ListIndex + 1), datos
Text7.Text = datos.producto
Text8.Text = datos.precio
Text9.Text = datos.existencias
Text10.Text = datos.subtotal
for d = 1 to list1.listcount-1
sum = sum + cint(datos.subtotal)
next d
text11.text = sum
Close #1
dim gh as string
gh = App.Path & "\facturas" & "\" & Prefix_Facturas & Text3.Text & ".TXT"
Open gh For Random As #1 Len = Len(datos)
Get #1, (List1.ListIndex + 1), datos
Text7.Text = datos.producto
Text8.Text = datos.precio
Text9.Text = datos.existencias
Text10.Text =[b] datos.subtotal[/b]
Close #1