Hola estoy haciendo un proyecto de factura y faltaria poner fecha y guardar los datos en archivo random
me guarda una parte text7.text,text8.text,text9.text,text10.text
pero no me guarda text11.text,text12.text,text13.text.
no se que hago mal
Option Explicit
Private Declare Function SendMessageArray Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Const LB_SETTABSTOPS = &H192
' Crear la Factura
Private Type Registro
nombre As String * 30
direccion As String * 25
poblacion As String * 30
telefono As String * 20
nif As String * 20
correo As String * 40
codigo As String * 30
producto As String * 25
precio As String * 30
cantidad As String * 10
existencias As String * 20
subtotal As Double
tre As Double
ivax As Double
totalx As Double
End Type
Dim datos As Registro
Private Type Type_Indices
Codigo_Facturas As Integer
End Type
Const Prefix_Facturas = "Fact" 'Asignamos un prefijo a las facturas para cuandos se guarden
Private Indices As Type_Indices
Private Sub Command1_Click()
' Nueva Factura
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text7.SetFocus
List1.Clear
Dim intfile As Integer
intfile = FreeFile
datos.tre = 0
Indices.Codigo_Facturas = Indices.Codigo_Facturas + 1
Label1.Caption = Indices.Codigo_Facturas
'GUARDAMOS EL CODIGO DE LA NUEVA FACTURA
Open App.Path & "\facturas\Indices.txt" For Random As intfile
Put #intfile, , Indices
Close #intfile
Label2.Caption = Space(10) & "Factura:"
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
'Guardar Datos
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text7.SetFocus
End Sub
Private Sub Command3_Click()
' Leer Factura
ReDim lbTab(1 To 4) As Long
lbTab(1) = 20
lbTab(2) = 186
lbTab(3) = 285
lbTab(4) = 405
SendMessageArray List1.hwnd, LB_SETTABSTOPS, 4, lbTab(1)
Dim n As Integer
Dim fencontrada As Boolean
Dim gh As String
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
List1.Clear
gh = App.Path & "\facturas" & "\" & Prefix_Facturas & Text3.Text & ".TXT"
Open gh For Random As #1 Len = Len(datos)
For n = 1 To LOF(1) / Len(datos)
Get #1, n, datos
fencontrada = True
Text3.Text = datos.producto
List1.AddItem vbTab & datos.producto & vbTab & datos.precio & vbTab & datos.existencias & vbTab & datos.subtotal
Next n
Text11.Text = datos.tre
Text11.Text = Format(Text11.Text, ".00")
Text12.Text = datos.ivax
Text12.Text = Format(Text12.Text, ".00")
Text13.Text = datos.totalx
Text13.Text = Format(Text13.Text, ".00")
Close #1
If Not fencontrada Then
MsgBox "La factura no existe.", vbCritical, "ERROR."
Kill gh
End If
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Command7_Click()
'Vender Articulos
ReDim lbTab(1 To 4) As Long
lbTab(1) = 20
lbTab(2) = 186
lbTab(3) = 285
lbTab(4) = 405
SendMessageArray List1.hwnd, LB_SETTABSTOPS, 4, lbTab(1)
datos.producto = Text7.Text
datos.precio = Text8.Text
datos.cantidad = Text9.Text
datos.subtotal = datos.cantidad * datos.precio
List1.AddItem vbTab & datos.producto & vbTab & datos.precio & vbTab & datos.cantidad & vbTab & datos.subtotal
datos.tre = datos.tre + datos.subtotal
If datos.tre > 0 Then
datos.ivax = datos.tre * 0.23
End If
If datos.tre > 0 And datos.ivax > 0 Then
datos.totalx = datos.tre + datos.ivax
End If
Dim pt As String
pt = App.Path & "\facturas" & "\" & Prefix_Facturas & Indices.Codigo_Facturas & ".TXT"
Open pt For Random As #1 Len = Len(datos)
datos.producto = Text7.Text
datos.precio = Text8.Text
datos.cantidad = Text9.Text
datos.subtotal = Text10.Text
datos.tre = Text11.Text
datos.ivax = Text12.Text
datos.totalx = Text13.Text
Put #1, LOF(1) / Len(datos) + 1, datos
Close #1
End Sub
Private Sub Form_Load()
If Dir(App.Path & "\facturas", vbDirectory) = "" Then
If MsgBox("OK Directorio ¡Facturas! Creado.", vbOKCancel) = vbOK Then
MkDir (App.Path & "\facturas")
Else
MsgBox " Directorio Facturas no Creado."
Exit Sub
End If
End If
Dim intfile As Integer
intfile = FreeFile
Open App.Path & "\facturas\Indices.txt" For Random As intfile
Get #intfile, , Indices
Close #intfile
Label1.Caption = Indices.Codigo_Facturas
End Sub
Private Sub List1_Click()
Dim gh As String
Dim toot As String
On Error Resume Next
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.cantidad
Text10.Text = datos.subtotal
Close #1
End Sub
Gracias