Menú

Mostrar Mensajes

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ú

Mensajes - corlo

#11
Programación Visual Basic / sumar list1
3 Diciembre 2021, 00:44 AM
Hola soy colro

necesito sumar el total contado y el total tarjeta de credito
consigo sumar el total del list1
pongo el codigo

Código (vb) [Seleccionar]


Case 1  ' Leer fichero de facturación
            FrmFile.Show 1
            Dim h As Integer
             Dim totalcontado As Integer
                Dim totaltcredito As Integer
                totalcontado = 0: totaltcredito = 0
            If (Len(FrmFile.File) > 0) Then
                If (LeerFacturacion(App.Path & "\" & FrmFile.File) = True) Then
                    Call Activar(True)
                   
                    For h = 0 To List1.ListCount - 1
                   
                     If reg2.MetodoDePago = "0" Then
                     totalcontado = totalcontado + Val(Split(List1.List(h), vbTab)(6))
                    End If
                    If reg2.MetodoDePago = "1" Then
                    totaltcredito = totaltcredito + Val(Split(List1.List(h), vbTab)(6))
                    End If
                    Next h
                    txttotal.Text = Format(totalcontado, "#,##0.00")
                    Txttotal1.Text = Format(totaltcredito, "#,##0.00")
                   
                Else
                    Call Activar(False)
                End If
            End If









Gracias
#12
gracias serapis

lo he podido descargar

lo he mirado por encima y funciona bien ya mirare los detalles con mas calma


muchas gracias
#13
Hola Serapis

gracias por poner el archivo de descarga, pero no lo puedo descargar

me sale
Secure Net ha bloqueado el contenido

El contenido de f65.workupload.com se ha considerado inseguro. Secure Net te recomienda cerrar esta página y seguir navegando.


me lo puedes poner en mediafire o por mega , gracias

#14
gracias serapis

primero no lo he podido terminar por que faltaban cosas

agregar a list1

lo de editar

lo retirar registro

tu trabajas con funciones , me has cambiado la manera de trabajar, tengo que seguir  con lo que dices tu, yo ya no puedo trabajar con lo que hacia yo.


Gracias
#15
Hola Serapis
gracias por el codigo

tengo unas dudas sobre el codigo

combuscar para buscar funcion buscararticulo como seria

comeditarregistro  no encuentro la funcion

comretirarregistro no encuentro la funcion


tengo un error en el optionbuton1 optionbuton2 me da un error en la funcion:
El miembro ya existe en un módulo de objeto con los controladores de este módulo de objeto

en los dos optionbuton le pongo en el nombre getmetodopago  y me pone el error



gracias
#16
Hola Serapis gracias por responder me ha ayudado bastante pero tengo dos dudas sobre el codigo que has puesto de lectura.

en donde dices leerfacturacion en el commandbutton7_click()


Código (vb) [Seleccionar]


Private Sub Command7_Click()
    If LeerFacturacion("poner aqui tu ruta") = True Then
        ' Activar en la interfaz lo que proceda
    Else
        ' desactivar de la interfaz lo que proceda
    End If
    ' para activar o desactivar es preferible tener una función que reciba un buleano y en base a ello activa o desactiva cada cosa que proceda... ya que también se llamaría desde 'cerrar'
End Sub



en donde dices, activar en la interfaz lo que proceda


supongo que es

[code=vb]

abierto=true



en donde dices , desactivar de la interfaz lo que proceda

Código (vb) [Seleccionar]

abierto=false





y lo segundo cuando haces el private sub posicionarregistro la variable lenb(reg1) que significa


Código (vb) [Seleccionar]


Private Sub PosicionarRegistro(ByVal Numregistro As Long)
    If (Abierto = True) Then
        Seek (Canal), (1 + ((Numregistro-1) * LenB(reg1)))
    End If
End Sub




gracias



seria bueno me pudiese hacer el codigo de  añadir un nuevo registro y guardarlo a fichero... incluso para buscar un determinado registro, para entender mejor el codigo, gracias




[/code]
#17
Hola soy corlo

estoy haciendo una mini aplicacion de guardar datos de factura y leerlos por pantalla, en archivo secuencial.

guardar datos lo hace bien

el problema esta en leer los datos de la factura en pantalla
el archivo es 1.txt y hay lo siguiente:


==============================
           COMPROBANTE DE VENTA
==============================
TICKET Nº: 1                    TIPO : CONTADO
FECHA : 20/11/2021          HORA : 20:30:59
-------------------------------------------------------
R.U.C/C.I : a
CLIENTE   : a
===============================
CANTIDAD  PRODUCTO     PRECIO       SUBTOTAL
===============================
12               r              8          96
3              k              1.5        4,5
===============================
              TOTAL :                           100,50
               -------------------------------------------

          GRACIAS POR SU COMPRA!



me sale todo mezclado


el código que tengo hasta ahora es el siguiente:


Código (vb) [Seleccionar]


Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192
Dim I As Integer
Dim orden As Integer 'numero de ticket
Dim fecha As Date 'para leer la fecha
Dim hora As Date 'para leer la hora
Dim contado As String 'para contado
Dim credito As String 'para  credito
Dim cedu1 As String ' para el RUC/C.I
Dim nom1 As String ' para el cliente
'abajo son datos del list1
Dim cantidad As Integer
Dim producto As String * 12
Dim preciox As String * 8
Dim subtot As Double
'varible del total
Dim tot As Double
Private Sub Command4_Click()
End
End Sub

Private Sub Command5_Click()
'Nuevo registro
'//recuperar el dato.
Open App.Path & "\Numero1.txt" For Input As #1
Do While Not EOF(1)
Input #1, orden
Loop
Close #1
Txtnum = orden + 1



      List1.Clear
     txtCedula1.Text = ""
     txtNombre1.Text = ""
     total.Text = ""
     txtCedula1.SetFocus


End Sub



Private Sub Command6_Click()
'Guardar Factura

Dim cantidadtotal As Double
Dim k As Integer


orden = Txtnum.Text
On Error GoTo salir





    Open App.Path & "\Numero1.txt" For Append As #1
   
    Print #1, Txtnum
    Close #1

Dim bmx As String
bmx = App.Path + "\" + Txtnum + ".txt"
   
  Open bmx For Append As #1
 
 
  Txtnum = orden
 
 
   
    Print #1,
   
    Print #1,
   
    Print #1,
   

    Print #1, Tab(1); String(44, "=")
    Print #1, Tab((44 - Len("COMPROBANTE DE VENTA")) \ 2); "COMPROBANTE DE VENTA"
    Print #1, Tab(1); String(44, "=")

    If Option1.Value = True Then
        Print #1, Tab(1); "TICKET Nº: " & Txtnum.Text; Tab(44 - Len("TIPO : CONTADO")); "TIPO : CONTADO"
    Else
        Print #1, Tab(1); "TICKET Nº: " & Txtnum.Text; Tab(44 - Len("TIPO : CREDITO")); "TIPO : CREDITO"
    End If

    Print #1, Tab(1); "FECHA : " & Date; Tab(44 - Len("HORA : " & Time)); "HORA : " & Time

    Print #1, Tab(1); String(44, "-")

    Print #1, Tab(1); "R.U.C/C.I : " & txtCedula1.Text
    Print #1, Tab(1); "CLIENTE   : " & txtNombre1.Text

    Print #1, Tab(1); String(44, "=")
    Print #1, Tab(1); "CANTIDAD"; Tab(11); "PRODUCTO"; Tab(24); "PRECIO"; Tab(37); "SUBTOTAL"
    Print #1, Tab(1); String(44, "=")
   
   
For k = 0 To List1.ListCount - 1
Print #1, List1.List(k)
Next k



    Print #1, Tab(1); String(44, "=")
    Print #1, Tab(15); "TOTAL : "; Tab(43 - Len(Format(total.Text, "#,##0.00"))); Format(total.Text, "#,##0.00")
    Print #1, Tab(16); "-----------------------------"


   
    Print #1,
    Print #1, Tab((44 - Len("GRACIAS POR SU COMPRA!")) \ 2); "GRACIAS POR SU COMPRA!"

    For I = 1 To 10
        Print #1,
    Next I
           
    Close #1
   
   
  Option1.Value = False
Option2.Value = False
       
txtCedula1.Text = ""
txtNombre1.Text = ""
    List1.Clear
cant.Text = ""
prod.Text = ""
precio.Text = ""
subtotal.Text = ""
total.Text = ""
cant.SetFocus
   
    Exit Sub

salir:

Dim msgb

msgb = MsgBox("Error Nº : [ " & Err.Number & " ]" & " " & Err.Description, vbOKCancel + vbInformation)


End Sub



Private Sub Command7_Click()
'Leer Factura
Dim tabs(0 To 3) As Long
    tabs(0) = 20
    tabs(1) = 60
    tabs(2) = 95
    tabs(3) = 138
    ' Set the tabs.
    SendMessage List1.hwnd, LB_SETTABSTOPS, 4, tabs(1)



Dim str As String
Dim thj As String
Dim plo As Boolean
Dim j As Integer
Dim h As Integer
On Error GoTo lo
List1.Clear
thj = App.Path + "\" + Txtnum.Text + ".txt"
If Dir(thj) <> "" Then
Open thj For Input As #1

Input #1, orden
Txtnum.Text = orden
Input #1, fecha
Label4.Caption = fecha
Input #1, hora
Label5.Caption = hora
Input #1, contado
Input #1, credito

Input #1, cedu1, nom1

txtCedula1.Text = cedu1
txtNombre1.Text = nom1

While Not EOF(1)

Input #1, cantidad, producto, preciox, subtot
cant.Text = cantidad
prod.Text = producto
precio.Text = preciox
subtotal.Text = subtot
List1.AddItem cantidad & vbTab & producto & vbTab & preciox & vbTab & subtot
Wend

j = 0
   For h = 0 To List1.ListCount - 1
j = j + Val(Split(List1.List(h), vbTab)(3))
Next h
total.Text = j



Close #1
End If

If contado= contado Then
Option1.Value = True
Else

If credito = credito Then
Option2.Value = True

End If
End If





Exit Sub
lo:
If Not plo = True Then
MsgBox "La Factura no existe, gracias", vbCritical
End If
End Sub

Private Sub Command8_Click()
'Agregar
Dim h As Integer
Dim j As Double

cantidad = cant.Text
producto = prod.Text
preciox = precio.Text
subtot = subtotal.Text

List1.AddItem cantidad & vbTab & producto & vbTab & preciox & vbTab & subtot
j = 0
   For h = 0 To List1.ListCount - 1
j = j + Split(List1.List(h), vbTab)(3)
Next h
total.Text = Format(j, "#,##0.00")
cant.Text = ""
prod.Text = ""
precio.Text = ""
subtotal.Text = ""
cant.SetFocus
End Sub

Private Sub Form_Load()
Dim tabs(0 To 3) As Long

    tabs(0) = 20
    tabs(1) = 123
    tabs(2) = 237
    tabs(3) = 370
   
    SendMessage List1.hwnd, LB_SETTABSTOPS, 4, tabs(1)
   
Option1.Value = False
Option2.Value = False
   
Open App.Path & "\Numero1.txt" For Append As #1
Close #1
Open App.Path & "\Numero1.txt" For Append As #1
Close #1

'//recuperar el dato.
Open App.Path & "\Numero1.txt" For Input As #1
Do While Not EOF(1)
Input #1, orden
Loop
Close #1
Txtnum = orden + 1

End Sub

Private Sub List1_Click()
Text1.Text = Mid(List1.Text, 1, InStr(1, List1.Text, " ") - 1)
Text2.Text = Mid(List1.Text, InStr(1, List1.Text, " ") + 1)
I = List1.ListIndex
End Sub






Private Sub Option1_Click()
Option2.Value = False
End Sub

Private Sub Option2_Click()
Option1.Value = False
End Sub

Private Sub precio_KeyUp(KeyCode As Integer, Shift As Integer)
subtotal.Text = cant.Text * Val(precio.Text)
End Sub

Private Sub Timer1_Timer()
Label4.Caption = Date
Label5.Caption = Format(Time, "hh:mm:ss")
End Sub







Gracias


#18
Programación Visual Basic / Re: eliminar registro
11 Noviembre 2021, 00:04 AM
Hola  Serapis


Muchas gracias por el codigo

todo correcto lo he adaptado y funciona

llevaba varios dias con el codigo y no me salia gracias.
#19
Programación Visual Basic / eliminar registro
9 Noviembre 2021, 19:14 PM
Hola soy corlo
estoy haciendo una mini aplicacion en añadir datos a los textbox ,  para luego leer los datos con el combo y una opcion para eliminar los datos.

añadir los datos: lo hace bien
leer los datos: lo hace bien
eliminar los datos: elimina el dato en el combo pero no elimina los datos de los textbox
no se que hago mal
paso el codigo que tengo hasta ahora

en un formulario



Option Explicit


Private Sub Boton_añadir_Click()
totalregistros = totalregistros + 1
If totalregistros > 50 Then
MsgBox "lista completa", 16, "error"
Else
agenda(totalregistros).Nombre = Nom.Text
agenda(totalregistros).apellidos = Ape.Text
agenda(totalregistros).telefono = Tel.Text
agenda(totalregistros).Edad = Val(Edad.Text)

Combo2.AddItem Nom.Text
End If
Nom.SetFocus
End Sub

Private Sub Boton_eliminar_Click()
Dim b As String

b = MsgBox("Eliminar Registro:" + Nom.Text, 3 + 32, "Eliminar")
If b = vbYes Then



If Combo2.ListIndex <> -1 Then




Combo2.RemoveItem (Combo2.ListIndex)



End If

totalregistros = totalregistros - 1

agenda(totalregistros).Nombre = Nom.Text
agenda(totalregistros).apellidos = Ape.Text
agenda(totalregistros).telefono = Tel.Text
agenda(totalregistros).Edad = Val(Edad.Text)





End If
Nom.Text = ""
Ape.Text = ""
Tel.Text = ""
Edad.Text = ""
End Sub

Private Sub Boton_fin_Click()
End
End Sub





Private Sub Botonnuevo_Click()
Nom.Text = ""
Ape.Text = ""
Tel.Text = ""
Edad.Text = ""
Nom.SetFocus

End Sub





Private Sub Combo2_Click()
Dim n As Integer
n = Combo2.ListIndex + 1

Nom.Text = agenda(n).Nombre
Ape.Text = agenda(n).apellidos
Tel.Text = agenda(n).telefono
Edad.Text = Val(agenda(n).Edad)



End Sub

Private Sub Ape_GotFocus()
Ape.SelStart = 0
Ape.SelLength = Len(Ape.Text)
End Sub

Private Sub Edad_GotFocus()
Edad.SelStart = 0
Edad.SelLength = Len(Edad.Text)
End Sub

Private Sub Nom_GotFocus()
Nom.SelStart = 0
Nom.SelLength = Len(Nom.Text)
End Sub
Private Sub Tel_GotFocus()
Tel.SelStart = 0
Tel.SelLength = Len(Tel.Text)
End Sub



Private Sub Form_Load()
totalregistros = 0
End Sub








y en un modulo




Type registro
Nombre As String * 15
apellidos As String * 25
telefono As String * 15
Edad As String * 3
End Type
Global agenda(1 To 50) As registro
Global totalregistros As Integer










gracias
#20
Hola soy  corlo


estoy haciendo un pequeño programa necesito descontar el valor que le pongo en el  text3.text
y lo cambie en el valor seleccionado del list1 de la columna 3


en el programa hay los siguientes objetos:

1 list1
1 list2

text1.text
text2.text
text3.text

1 command1 salida
1 command4 ok

la cuestion es que cuando aprieto el command1 la operacion de resta lo hace bien, cuando voy a el command4 no consigo poner el resultado del text3.text  en el list1 del valor seleccionado de la columna 3

aqui esta el codigo que tengo hasta ahora:




Option Explicit






Private Sub Command1_Click()
'salida ok


Dim i As Long
Dim arrString() As String
For i = 0 To UBound(arrString)
    List1.AddItem arrString(i)
Next

End Sub

Private Sub Command3_Click()
Unload Me
Form1.Show
End Sub

Private Sub Command4_Click()
'Salida
Dim cantidad As Integer
cantidad = Text1.Text

If Text3.Text > cantidad Then
   MsgBox "No hay suficiente existencia", vbCritical
   Exit Sub
End If

Command1.Visible = True
Text3.Text = Text3.Text - Text1.Text
End Sub

Private Sub Form_Load()
List1.AddItem "p001" & "                     " & "descripciom p001" & "                           " & "42"
List1.AddItem "p002" & "                     " & "descripciom p002" & "                           " & "53"
List1.AddItem "p003" & "                     " & "descripciom p003" & "                           " & "244"
List1.AddItem "p004" & "                     " & "descripciom p004" & "                           " & "75"
Text2.Text = List1.ListCount
Command1.Visible = False
End Sub

Private Sub List1_Click()

    Dim x As Integer
  List2.Clear
   
  List2.AddItem List1.Text

    For x = 0 To List2.ListCount - 1
   
   Text1.Text = Mid(List2.List(x), Len(List2.List(x)) - 2, 3)

   
   Next x
   
   
End Sub







he probado varias formas pero no consigo cambiar el valor del text3 al list1

gracias