CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2016
    Posts
    3

    modify random file

    Hi I'm oncro
    I would like to modify an item from list1 it does well but not the total sum me text11.text


    Code:
    Private Type Registrot
    codigo As String * 30
    producto As String * 25
    precio As String * 30
    existencias As String * 20
    cantidad As String * 10
    subtotal As String * 20
    End Type
    Dim formax As Registrot
    
    
    
    
    
    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 String * 10
    tre As Double
    ivax As Double
    totalx As Double
    End Type
    Dim datos As Registro
    
    
    Dim toot As String
    Dim pg As String
    
    
    If List1.ListIndex < 0 Then
    MsgBox "Ningún elemento ha sido seleccionado", vbInformation
    Exit Sub
    End If
    
    
    pg = App.Path & "\productos\" & Text7.Text
    Open pg For Random As #1 Len = Len(formax)
    
    toot = Val(Text9.Text) - Val(datos.existencias)
    
    If Val(toot) = -1 Then
    MsgBox ("No hay  mas material de venta de " & datos.producto & "¡¡¡¡¡¡¡error!!!!!!!!")
    Text14.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text10.Text = ""
    Combo2.Text = ""
    Close #1
    Exit Sub
    End If
    formax.codigo = Text15.Text
    formax.producto = Text7.Text
    formax.precio = Text8.Text
    formax.existencias = Text14.Text
    formax.subtotal = Text10.Text
    Put #1, , formax
    Close #1
    
    
    Text10.Text = Val(toot) * Text8.Text
    
    
    Dim gk As String
    
    gk = App.Path & "\facturas" & "\" & Prefix_Facturas & Indices.Codigo_Facturas & ".TXT"
    
    Open gk For Random As #1 Len = Len(datos)
    datos.nombre = Trim(Combo1.Text)
    datos.poblacion = Text1.Text
    datos.direccion = Text2.Text
    datos.telefono = Text4.Text
    datos.nif = Text5.Text
    datos.correo = Text6.Text
    datos.producto = Text7.Text
    datos.precio = Text8.Text
    datos.existencias = Val(toot)
    datos.subtotal = Text10.Text
    datos.tre = Text11.Text
    Text11.Text = Format(Text11.Text, ".00")
    datos.ivax = Text12.Text
    Text12.Text = Format(Text12.Text, ".00")
    datos.totalx = Text13.Text
    Text13.Text = Format(Text13.Text, ".00")
    Put #1, List1.ListIndex + 1, datos
    Close #1

    thanks

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: modify random file

    You need to be a bit more detailed in your question. As is I can not tell what you are trying to ask.
    I also do not see anywhere in the code that assigns a value to text11
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Feb 2016
    Posts
    3

    Re: modify random file

    Hi I'm oncro
    I would like to modify an item from list1 it does well but not the total sum me text11.text


    Code:
    Private Type Registrot
    codigo As String * 30
    producto As String * 25
    precio As String * 30
    existencias As String * 20
    cantidad As String * 10
    subtotal As String * 20
    End Type
    Dim formax As Registrot
    
    
    
    
    
    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 String * 10
    tre As Double
    ivax As Double
    totalx As Double
    End Type
    Dim datos As Registro
    
    
    Dim toot As String
    Dim pg As String
    
    
    
    
    
    
    commandbutton1_click()
    
    If List1.ListIndex < 0 Then
    MsgBox "Ningún elemento ha sido seleccionado", vbInformation
    Exit Sub
    End If
    
    
    pg = App.Path & "\productos\" & Text7.Text
    Open pg For Random As #1 Len = Len(formax)
    
    toot = Val(Text9.Text) - Val(datos.existencias)
    
    If Val(toot) = -1 Then
    MsgBox ("No hay  mas material de venta de " & datos.producto & "¡¡¡¡¡¡¡error!!!!!!!!")
    Text14.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text10.Text = ""
    Combo2.Text = ""
    Close #1
    Exit Sub
    End If
    formax.codigo = Text15.Text
    formax.producto = Text7.Text
    formax.precio = Text8.Text
    formax.existencias = Text14.Text
    formax.subtotal = Text10.Text
    Put #1, , formax
    Close #1
    
    
    Text10.Text = Val(toot) * Text8.Text
    
    
    Dim gk As String
    
    gk = App.Path & "\facturas" & "\" & Prefix_Facturas & Indices.Codigo_Facturas & ".TXT"
    
    Open gk For Random As #1 Len = Len(datos)
    datos.nombre = Trim(Combo1.Text)
    datos.poblacion = Text1.Text
    datos.direccion = Text2.Text
    datos.telefono = Text4.Text
    datos.nif = Text5.Text
    datos.correo = Text6.Text
    datos.producto = Text7.Text
    datos.precio = Text8.Text
    datos.existencias = Val(toot)
    datos.subtotal = Text10.Text
    
    
    datos.tre = Text11.Text
    Text11.Text = Format(Text11.Text, ".00")
    
    
    datos.ivax = Text12.Text
    Text12.Text = Format(Text12.Text, ".00")
    datos.totalx = Text13.Text
    Text13.Text = Format(Text13.Text, ".00")
    Put #1, List1.ListIndex + 1, datos
    Close #1
    
    end sub
    the value text11.text this but what I wonder is how to summing the total text11.text,
    I wonder how it is done to summing in text11.text source code?
    thanks

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: modify random file

    I have no idea what you mean. You can not really get a total nor a sum from a single entry as it would simply be that entry. A sum means that you are adding 2 or more things together. Total of course could be using other math operations as well as adding. Your description does not provide required details.

    In general to get a sum you use simple math as in Total=A+B+C or whatever your case may be
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured