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 - GhostLT

#71
Gracias Komodo!!!
Puse hasta arriba la declaración
Código (cpp) [Seleccionar]
int FuncionVulnerable(char *cptr);/code]

y modifique

[code=cpp] int LeerFichero(char*Fbuffer,char*Fnombre, int Limite)
  ;-)[/code]
#72
Me atore y no se x que y creo que todo esta bien declarado y el archivo.txt se encuentra dentro de la carpeta donde guarde mi proyecto

Errores:
26 `FuncionVulnerable' undeclared (first use this function)
39 invalid conversion from `char' to `const char*'
39 initializing argument 1 of `FILE* fopen(const char*, const char*)'
56`int FuncionVulnerable(char*)' used prior to declaration


Código (cpp) [Seleccionar]
#include <cstdlib>
#include <iostream>

using namespace std;

/* declaramos la funcion que usaremos para leer el fichero*/

int LeerFichero(char*, char*, int);


int main()

{

/* esta es la funcion principal en la que declaramos una variable de tipo char que
contendra el string recogido desde "archivo.txt"*/
       
        char buffer[1000];
        char nombre[]="archivo.txt";

/* tras declarar las variables llamamos a la funcion leer fichero() que metera en la
variable buffer el contenido del archivo.txt, luego llamaremos a la funcion vulnerable
para que copie el contenido de este a una variable de buffer de menor tamaño que esta */

        LeerFichero(buffer,nombre,1000);
        FuncionVulnerable(buffer);
        system("pause");
        return 0;
}

/* la funcion leer fichero, abre el fichero, lo lee y lo guarda en la variable buffer */

int LeerFichero(char*Fbuffer, char Fnombre, int Limite)
{
        int c;
        int n=0;

        FILE *f;
        f=fopen(Fnombre,"r");
        while ((c=getc(f))!=EOF)
        {
                if(n<Limite)
                {Fbuffer[n++]=c;}
        }
        Fbuffer[n++]=0;
        fclose(f);
        return 0;
}

/* funcion vulnerable. Esta funcion es lo importante de este codigo, en esta función
recibimos el puntero donde se encuentra la variable que contiene el texto introducido
en archivo.txt. La funcion copiara el contenido de esta variable a una variable de tipo char
de un tamaño inferior a la variable buffer. seguidamente mostrara el contenido de esta.*/

int FuncionVulnerable(char *cptr)
{
        char buff[300]= "Datos";
        strcpy(buff,cptr);
        printf("%s\n\n",buff);
        return 0;
}


/* Funcion Oculta. Ninguna de las otras funciones anteriares llama a esta */

int FuncionOculta()
{
        printf("Este texto nunca deberia de mostrarse");
        return 0;
}
/code]

#73
La función Val convierte una cadena en un número
Ejemplo:

cadena = "123456"
cadena = Val(cadena)

La función Str un número en una cadena.
Ejemplo:

'Ahora cadena vale 123456

cadena2 = 123456
cadena2 = Str(cadena2)

'Ahora cadena2 vale "123456"
#74
Aqui esta corregido el link freddyjose00
#75
Haber si te sirve este es un ocx
Descarga

Megaupload
Descarga
#76
Primero que nada GRACIAS!!! por mencionar las etiquetas geSHI no tenia idea como le hacian, apartir de ahora las voy a implementar para una mejor comprensión y con respecto a la info del with es cierto intentaré poner mas cuidado.   :D
#77
Uff!!! porfin encontre la solución
Private Sub cmdagregar_Click()
'validar que esten seleccionados los campos
'If txtmaterial.Text = "" Then MsgBox " Seleccione el tipo de Material", vbInformation, "Aviso": Exit Sub
If Combo2.Text = "" Then MsgBox "Seleccione Medida de Largo", vbInformation, "Aviso": Exit Sub
If Combo3.Text = "" Then MsgBox "Seleccione la Cantidad a Imprimir", vbInformation, "Aviso": Exit Sub
If Combo1.Text = "" Then MsgBox "Desea Aplicar Descuento", vbInformation, "Aviso": Exit Sub
If txtentrega.Text = "" Then MsgBox "Seleccione Fecha de Entrega", vbInformation, "Aviso": Exit Sub
'------------------------------validar que la info del detalle de la venta no sea igual----
var1 = txtmaterial.Text + txtancho.Text + Combo2.Text
Dim Registros As Integer
Registros = ListView1.ListItems.Count

For x = 1 To Registros
With ListView1
    var2 = ListView1.ListItems.item(x) & ListView1.ListItems.item(x).ListSubItems(1) & ListView1.ListItems.item(x).ListSubItems(2) & " mts"
End With
If var1 = var2 Then MsgBox "Esta Información ya ha sido agregado a esta compra anteriormente", vbInformation, "Aviso": limpiar: Exit Sub
Next

'grabar en TemporalFacturaPlotter
With RsTemporalFacturaPlotter
    .Requery
    .AddNew
    !material = txtmaterial.Text
    !medidaancho = CDbl(txtancho.Text)
    !medidalargo = CDbl(txtlargo.Text)
    !cantidad = txtcantidad.Text
    !descuento = CDbl(txtdescuento.Text)
    !importe = CDbl(txtimporte.Text)
    !semana = lblsemana.Caption
    !Hora = lblhora.Caption
    .Update
End With
agregar                     'llena el listview1 con los datos que meti
'calcular los totales
txtsubtotal.Text = Sumar    'suma toda la lista de precios del campo precio del listview1
txtiva.Text = txtsubtotal.Text * 0.1
txttotal.Text = txtsubtotal.Text + txtsubtotal.Text * 0.1
limpiar         'limpia todo el pedo
End Sub
'End Function
Private Function Sumar() As Double
   
    Dim i As Integer
    'Recorre todos los items y para sumar los SubItems
    For i = 1 To ListView1.ListItems.Count
        Sumar = Sumar + CDbl(ListView1.ListItems.item(i).ListSubItems(7))
    Next i
       
End Function
#78
 Es necesario consultar 3 campos en el listview para determinar que no esta repetido (material,medidaancho y medidalargo) si estos 3 son verdadero entonces que me mande un mensaje que ya esta en la lista

Private Sub cmdagregar_Click()
'validar que esten seleccionados los campos
If txtmaterial.Text = "" Then MsgBox " Seleccione el tipo de Material", vbInformation, "Aviso": Exit Sub
If Combo2.Text = "" Then MsgBox "Seleccione Medida de Largo", vbInformation, "Aviso": Exit Sub
If Combo3.Text = "" Then MsgBox "Seleccione la Cantidad a Imprimir", vbInformation, "Aviso": Exit Sub
If Combo1.Text = "" Then MsgBox "Desea Aplicar Descuento", vbInformation, "Aviso": Exit Sub
If txtentrega.Text = "" Then MsgBox "Seleccione Fecha de Entrega", vbInformation, "Aviso": Exit Sub
'validar que el producto no se encuentre ya en el detalle
Dim i As Long
Dim j As Long
With ListView1
    .View = lvwList
For i = 1 To .ListItems.Count
For j = i + 1 To .ListItems.Count
If .ListItems.item(i).ListItems.item(i).SubItems(1) And .ListItems.item(i).SubItems(2) = .ListItems.item(j) And _
                                                                 .ListItems.item(j).SubItems(1) And .ListItems.item(j).SubItems(2) Then
MsgBox "Esa Información ya existe en la lista de Facturación", vbInformation, "Aviso": Exit Sub
End If
If j = .ListItems.Count Then
Exit For
End If
Next

With RsTemporalFacturaPlotter
    .Requery
    .AddNew
    !material = txtmaterial.Text
    !medidaancho = CDbl(txtancho.Text)
    !medidalargo = CDbl(txtlargo.Text)
    !cantidad = txtcantidad.Text
    !descuento = CDbl(txtdescuento.Text)
    !importe = CDbl(txtimporte.Text)
    !semana = lblsemana.Caption
    !Hora = lblhora.Caption
    .Update
End With
agregar                     'llena el listview1 con los datos que meti
'calcular los totales
txtsubtotal.Text = Sumar    'suma toda la lista de precios del campo precio del listview1
txtiva.Text = txtsubtotal.Text * 0.1
txttotal.Text = txtsubtotal.Text + txtsubtotal.Text * 0.1
limpiar         'limpia todo el pedo
End Sub

Gracias por su atención
#79
Muchas gracias por el comentario le he estado dando toda la noche y logre lo que necesitaba me quedo de esta manera
'agregar detalle
Dim Registros As Integer
Registros = RsTemporalFacturaPlotter.RecordCount
RsTemporalFacturaPlotter.Requery
RsTemporalFacturaPlotter.MoveFirst
For x = 1 To Registros
With RsDetalleFacturaPlotter
    .Requery
    .AddNew
    !Factura = txtfactura.Text
    '!fecha = Date
    !material = ListView1.ListItems.item(x)
    !medidaancho = ListView1.ListItems.item(x).ListSubItems(1)
    !medidalargo = ListView1.ListItems.item(x).ListSubItems(2)
    !cantidad = ListView1.ListItems.item(x).ListSubItems(3)
    !descuento = ListView1.ListItems.item(x).ListSubItems(5)
    !importe = ListView1.ListItems.item(x).ListSubItems(7)
    !semana = lblsemana.Caption
    !Hora = lblhora.Caption
    .Update
End With
If x = Registros Then Else RsTemporalFacturaPlotter.MoveNext
Next
'enviar un mensaje de confirmacion: se facturo correctamente
MsgBox "La factura fue creada correctamente", vbInformation, "Aviso"
Unload Me
MenuPrincipalForm.Show
#80
A la hora de guardar la lista en mi base de datos
With RsDetalleFacturaPlotter
    .Requery
    .AddNew
>  !material = ListView1.ListItems(1)
    !medidaancho = ListView1.ListItems(2)
    !medidalargo = ListView1.ListItems(2)
    !cantidad = ListView1.ListItems(4)
    !descuento = ListView1.ListItems(5)
    !importe = ListView1.ListItems(6)
    !fechadeentrega = ListView1.ListItems(7)
    .Update
End With
Me aparece un error que dice:
El indice está fuera de los limites
Si necesitan mas información porfavor preguntenme esque no me se explicar muy bien ya busque información y los ejemplos que encontré no son lo que yo necesito  -------------------------------------------:huh:--------------------------------------------