Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - errore quando uso il call
Forum - Visual Basic 6 - errore quando uso il call

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
islington (Normal User)
Newbie


Messaggi: 8
Iscritto: 26/06/2022

Segnala al moderatore
Postato alle 16:19
Domenica, 26/06/2022
salve a tutti ho un problema con un programma di contabilita secolare che ho rispolverato ed alla quale volevo fare qualche modifica, ma sono molto arrugginito  ed il progamma era gia fatto un po così
praticamente richiamando una routine che mi esgue calcoli in automatico, quando vado a prendere gli articoli dal database mi prende solo il prezzo senza prelevare codice e descrizione, do ho errato?
cerco di postare le due parti di codice interessato,  è un po lungo e non so
questo è il codice del preventibo

Option Compare Text
Dim salva As Boolean
Dim flag As Boolean
Dim T_IVA As Double, t_netto As Double
Dim attuale As Integer
#If Win32 Then

      Private Declare Function SetBkMode Lib "gdi32" _
      (ByVal hDC As Long, ByVal nBkMode As Long) As Long

      Private iBKMode As Long

   #Else

      Private Declare Function SetBkMode Lib "GDI" (ByVal hDC As Integer _
       , ByVal nBkMode As Integer) As Integer

      Private iBKMode As Integer

   #End If

      Private Const TRANSPARENT = 1
      Private Const OPAQUE = 2
Public Sub riordino()
    
   ' DB_PREV.Refresh
   ' DB_PREV.Recordset.MoveLast

    DBGrid1.Columns(0).Visible = False
    DBGrid1.Columns(1).Visible = False
    DBGrid1.Columns(2).Visible = False
    DBGrid1.Columns(3).Width = 720
    DBGrid1.Columns(3).Alignment = 2
    DBGrid1.Columns(4).Width = 1120
    DBGrid1.Columns(4).Alignment = 2
    DBGrid1.Columns(5).Width = 5900
    DBGrid1.Columns(6).Width = 600
    DBGrid1.Columns(6).Alignment = 2
    DBGrid1.Columns(7).Width = 1100
    DBGrid1.Columns(7).Alignment = 2
    DBGrid1.Columns(8).Width = 1000
    DBGrid1.Columns(9).Width = 1000
    DBGrid1.Columns(10).Width = 1000
    DBGrid1.Columns(11).Width = 1000
    DBGrid1.Columns(12).Width = 1000
    DBGrid1.Columns(13).Width = 1000
    DBGrid1.Columns(14).Width = 1000
    DBGrid1.Columns(15).Width = 700
    DBGrid1.Columns(16).Width = 1000
'    DBGrid1.SetFocus


End Sub
Function dividi(descr As String, l As Integer) As String
Dim cont As Integer
Dim lung As Integer
Dim spazio As String
    ' Lunghezza stringa restituita
    lung = l
    If Len(descr) <= lung Then
        dividi = descr
    Else
        cont = lung
        spazio = Mid(descr, lung, 1)
        While Not spazio = " "
            cont = cont - 1
            spazio = Mid(descr, cont, 1)
        Wend
        dividi = Mid(descr, 1, cont)
    End If
End Function

Private Sub CANCELLA()
    Des.Text = ""
    Um.Text = ""
    Prunit.Text = ""
    Prscont.Text = ""
    Sconto.Text = ""
    IVA.Text = ""
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
End Sub

Private Sub Stampa(pagina As Integer, stringa As String)
    If pagina = 0 Or pagina = attuale Then
        Printer.Print stringa
    End If
End Sub

Private Sub Bt_addnota_Click()
    If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
        Note.Text = DB_STOPRE.Recordset("NOTE")
    Else
        Note.Text = ""
    End If
    Note.Visible = True
    L_note.Visible = True
    BT_insnota.Visible = True
    Bt_annota.Visible = True
    BT_parz.Visible = False
    BT_forn.Visible = False
    BT_var.Visible = False
    Note.SetFocus
    Bt_addnota.Visible = False
    Call riordino
    'Call Calcoli
End Sub


Private Sub BT_AnNota_Click()
    Note.Visible = False
    L_note.Visible = False
    BT_insnota.Visible = False
    Bt_annota.Visible = False
    BT_parz.Visible = True
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_forn.Visible = True
    DBGrid1.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub BT_annvoce_Click()
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_sta.Visible = True
    scelta.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    flag = False
    DB_PREV.Recordset.MoveLast
    DB_PREV.Recordset.Delete
    DB_PREV.Recordset.MoveLast
    DBGrid1.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub Bt_cancVoce_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
    If Not DB_PREV.Recordset.EOF Then
        tipo_finmsg = 4
        Msg = "Conferma la Cancellazione della voce dal documento ?"
        If MsgBox(Msg, tipo_finmsg, "Cancella da Documento") = 6 Then
            DB_PREV.Recordset.Delete
            DB_PREV.Recordset.MoveNext
            If DB_PREV.Recordset.EOF Then
                DB_PREV.Refresh
                If Not DB_PREV.Recordset.EOF Then DB_PREV.Recordset.MoveLast
            End If
            DBGrid1.SetFocus
           ' Me.Timer1.Enabled = True
           Call Calcoli
        Call riordino
          
        End If
    End If
    'Call riordino
    'Call Calcoli
End Sub

Private Sub BT_elart_Click()
    scelta.ZOrder 0
    scelta.Visible = True
End Sub

Private Sub BT_forn_Click()
    F_CAMFOR.cliente = DB_STOPRE.Recordset("CLIENTE")
    F_CAMFOR.NORD = NORD.Text
    F_CAMFOR.DATA = DATA.Text
    F_PREINS.Hide
    F_CAMFOR.Show
End Sub

Private Sub BT_insnota_Click()
    DB_STOPRE.Recordset.Edit
    DB_STOPRE.Recordset("NOTE") = Note.Text
    DB_STOPRE.Recordset.Update
    Note.Visible = False
    L_note.Visible = False
    BT_insnota.Visible = False
    Bt_annota.Visible = False
    BT_parz.Visible = True
    BT_var.Visible = True
    BT_forn.Visible = True
    Bt_addnota.Visible = True
    DBGrid1.SetFocus
End Sub

Private Sub BT_insvoce_Click()
    IVA.Text = DB_STOPRE.Recordset("IVA")
    salva = True
    DB_PREV.Recordset.Edit
    DB_PREV.Recordset("NUMERO") = NORD.Text
    If Qty.Text <> "" And Prscont.Text <> "" Then
        DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
        End If
     If Qty.Text <> "" And UDC.Text <> "" Then
         DB_PREV.Recordset("Tot_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
          End If
        If Qty.Text <> "" And MANOD.Text <> "" Then
         DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
          End If
          
    DB_PREV.Recordset.Update
    salva = False
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_sta.Visible = True
    BT_newvoce.Visible = True
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_elart.Visible = False
    scelta.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    DB_PREV.Recordset.MoveLast
    DBGrid1.SetFocus
    flag = False
    
    Call Calcoli
   Call riordino
    
   ' DBGrid1.SetFocus
        End Sub


Private Sub BT_modvoce_Click()
    If Not DB_PREV.Recordset.EOF Then
        salva = True
        DB_PREV.Recordset.Edit
        If Qty.Text <> "" And Prscont.Text <> "" Then
            DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
            End If
        If Qty.Text <> "" And UDC.Text <> "" Then
            DB_PREV.Recordset("TOT_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
         End If
             If Qty.Text <> "" And MANOD.Text <> "" Then
            DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
         End If
        
       DB_PREV.Recordset.Update
            salva = False
        DBGrid1.SetFocus
    End If
    Call Calcoli
    Call riordino
    
End Sub


Private Sub BT_newvoce_Click()
   ' flag = True
    DB_PREV.Recordset.AddNew
    DB_PREV.Recordset("NUMERO") = NORD.Text
    DB_PREV.Recordset.Update
    'con il seguente comando aggiunge voce sempre e solo alla fine del database
    DB_PREV.Recordset.MoveLast
    Casa.Text = ""
    Codice.Text = ""
    Des.Text = ""
    Um.Text = ""
    UDC.Text = ""
    TOT_UDC.Text = ""
    MANOD.Text = ""
    TMANOD.Text = ""
    Prunit.Text = ""
    Prscont.Text = ""
    Sconto.Text = ""
    IVA.Text = ""
    BT_var.Visible = False
    BT_elart.Visible = True
    BT_sta.Visible = False
    BT_insnota.Visible = False
   flag = True
    Bt_annota.Visible = False
    L_note.Visible = False
    Note.Visible = False
    Bt_addnota.Visible = False
    BT_parz.Visible = False
    BT_newvoce.Visible = False
    BT_insvoce.Visible = True
    BT_annvoce.Visible = True
    BT_modvoce.Visible = False
    BT_forn.Visible = False
    BT_cancvoce.Visible = False
    Call riordino
    'Call Calcoli
    Casa.SetFocus
  
End Sub

Private Sub Calcoli()
Dim tipo_finmsg As String
Dim Msg As String
Dim IMPO, IVA, TUDC, TMANOD As Double
    IMPO = 0
    TUDC = 0
    IVA = 0
    TMANOD = 0
    TOT1 = 0
    UTIMP = 0
  '  DB_PREV.Refresh
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
            IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
          End If
        
          If Not IsNull(DB_PREV.Recordset("TOT_UDC")) Then
             TUDC = TUDC + DB_PREV.Recordset("TOT_UDC")
         End If
      
        If Not IsNull(DB_PREV.Recordset("TMANOD")) Then
             TMANOD = TMANOD + DB_PREV.Recordset("TMANOD")
         End If
        DB_PREV.Recordset.MoveNext
        On Error GoTo errore
     Wend
    
    IVA = IMPO * DB_STOPRE.Recordset("IVA") / 100
    TOT1 = TUDC + TMANOD
    UTIMP = IMPO - TOT1
    tipo_finmsg = 0
    
    tot.Caption = Format(IMPO, F_MENU.FormatoEuro)
    IVA1.Caption = Format(IVA, F_MENU.FormatoEuro)
    impo1.Caption = Format(IMPO + IVA, F_MENU.FormatoEuro)
    TUDC1.Caption = Format(TUDC, F_MENU.FormatoEuro)
    TMANOD1.Caption = Format(TMANOD, F_MENU.FormatoEuro)
    manodudc.Caption = Format(UTIMP + TMANOD, F_MENU.FormatoEuro)
    utilimp.Caption = Format(IMPO - TOT1, F_MENU.FormatoEuro)
    
    
   ' Msg = "IL TOTALE DEI CALCOLI DI PREVENTIVO é " & Chr$(13)
   ' Msg = Msg & Chr$(13)
   ' Msg = Msg & "IMPONIBILE : " & Chr$(32) & Format(IMPO, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "IVA        : " & Format(IVA, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "TOTALE     : " & Format(IMPO + IVA, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
    
   ' Msg = Msg & "TOTALE U.D.C.   : " & Format(TUDC, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "TOT. MANOD      : " & Format(TMANOD, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
   ' Msg = Msg & "MANOD + UDC     : " & Format(TUDC + TMANOD, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "UTILE IMP.      : " & Format(IMPO - TOT1, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
   ' If MsgBox(Msg, tipo_finmsg, "CALCOLI PREVENTIVO") = 1 Then
    'End If
'    DB_PREV.Refresh
'    DB_PREV.Recordset.MoveLast

        
   '     End If
     ' salva = False
      
     ' Call riordino
   '  Me.Timer1.Enabled = True
Exit Sub
errore:
   MsgBox "è inrtervenuto un erroe !", vbExclamation
   On Error Resume Next
  
End Sub

Private Sub BT_sta_Click()
Dim I As Byte
    DB_STAMPANTI.DatabaseName = CurDir & "\SEA.mdb"
    DB_STAMPANTI.RecordSource = "db_stampanti"
    DB_STAMPANTI.Refresh
    I = DB_STAMPANTI.Recordset("IMPOSTATA")
    attualmente.Text = Printers(I).DeviceName
    For I = 0 To Printers.Count - 1
        Stamp.AddItem Printers(I).DeviceName, I
    Next I
    st.ZOrder 0
    Contratto.Value = 0
    st.Visible = True
    Call riordino
    'Call Calcoli
End Sub

Private Sub BT_var_Click()
    Variazione.ZOrder 0
    Variazione.Visible = True
    var.Text = ""
    var.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub Casa_LostFocus()
Dim esegui As Boolean
    Casa.Text = UCase(Casa.Text)
    esegui = True
    If Codice.Text <> "" And flag Then
        DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTASS.Refresh
        If Not DB_ARTASS.Recordset.EOF Then
            Casa = DB_ARTASS.Recordset("CASA")
            Codice = DB_ARTASS.Recordset("CODICE")
            Des = DB_ARTASS.Recordset("DESCRIZIONE")
            Um = DB_ARTASS.Recordset("UM")
            UDC = DB_ARTASS.Recordset("UDC")
            MANOD = DB_ARTASS.Recordset("Manod")
            Costo = DB_ARTASS.Recordset("COSTO")
            Ricarico = DB_ARTASS.Recordset("RICARICO")
            Prunit = DB_ARTASS.Recordset("LISTINO")
            Prscont = DB_ARTASS.Recordset("LISTINO")
            IVA = DB_ARTASS.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        If esegui Then
        DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTICOLI.Refresh
        If Not DB_ARTICOLI.Recordset.EOF Then
            Casa = DB_ARTICOLI.Recordset("CASA")
            Codice = DB_ARTICOLI.Recordset("CODICE")
            Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
            Um = DB_ARTICOLI.Recordset("UM")
            Costo = DB_ARTICOLI.Recordset("COSTO")
            UDC = DB_ARTICOLI.Recordset("costo")
            Ricarico = DB_ARTICOLI.Recordset("RICARICO")
            Prunit = DB_ARTICOLI.Recordset("LISTINO")
            Prscont = DB_ARTICOLI.Recordset("LISTINO")
            IVA = DB_ARTICOLI.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        End If
    End If
End Sub

Private Sub codice_LostFocus()
Dim esegui As Boolean
    Codice.Text = UCase(Codice.Text)
    esegui = True
    If Casa.Text <> "" And flag Then
        DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTASS.Refresh
        If Not DB_ARTASS.Recordset.EOF Then
            Casa = DB_ARTASS.Recordset("CASA")
            Codice = DB_ARTASS.Recordset("CODICE")
            Des = DB_ARTASS.Recordset("DESCRIZIONE")
            Um = DB_ARTASS.Recordset("UM")
            UDC = DB_ARTASS.Recordset("UDC")
            MANOD = DB_ARTASS.Recordset("Manod")
            Costo = DB_ARTASS.Recordset("COSTO")
            Ricarico = DB_ARTASS.Recordset("RICARICO")
            Prunit = DB_ARTASS.Recordset("LISTINO")
            Prscont = DB_ARTASS.Recordset("LISTINO")
            IVA = DB_ARTASS.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        If esegui Then
        DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTICOLI.Refresh
        If Not DB_ARTICOLI.Recordset.EOF Then
            Casa = DB_ARTICOLI.Recordset("CASA")
            Codice = DB_ARTICOLI.Recordset("CODICE")
            Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
            Um = DB_ARTICOLI.Recordset("UM")
            UDC = DB_ARTICOLI.Recordset("COSTO")
            Costo = DB_ARTICOLI.Recordset("COSTO")
            Ricarico = DB_ARTICOLI.Recordset("RICARICO")
            Prunit = DB_ARTICOLI.Recordset("LISTINO")
            Prscont = DB_ARTICOLI.Recordset("LISTINO")
            IVA = DB_ARTICOLI.Recordset("IVA")
      
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
             Call CANCELLA
        End If
        End If
    End If
End Sub

Private Sub Command1_Click()
    With F_ARTRMO
        .L_DocP.Visible = True
        .mnuart.Enabled = False
        .mnumenu.Enabled = False
        .BT_REGMOD.Visible = False
        .BT_CANCELLA.Visible = False
        .BT_pins.Visible = True
        .BT_pann.Visible = True
    End With
    scelta.Visible = False
    F_ARTRMO.Caption = "Inserimento Articoli Singoli in Preventivo"
    F_PREINS.Hide
    F_ARTRMO.Show
End Sub

Private Sub Command2_Click()
    With F_ASSRMO
        .L_DocP.Visible = True
        .mnuart.Enabled = False
        .mnumenu.Enabled = False
        .BT_REGMOD.Visible = False
        .BT_CANCELLA.Visible = False
        .BT_pins.Visible = True
        .BT_pann.Visible = True
    End With
    scelta.Visible = False
    F_ARTRMO.Caption = "Inserimento Articoli Assemblati in Preventivo"
    F_PREINS.Hide
    F_ASSRMO.Show
End Sub

Private Sub Command3_Click()
    scelta.Visible = False
End Sub
Private Sub Command6_Click()
    Stamp.Clear
    st.Visible = False
End Sub

Private Sub dis_modello()
    ' verticali
'   Printer.Line (42, 8.5)-(95, 8.5)
    Printer.Line (42, 16.5)-(95, 16.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 14.5)-(42, 14.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 20.5)-(95, 20.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 22.5)-(95, 22.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 52.5)-(84.5, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (12, 54.5)-(62, 54.5) ', RGB(184, 227, 254), BF
    Printer.Line (8, 56)-(62, 56) ', RGB(184, 227, 254), BF
    Printer.Line (8, 57.5)-(62, 57.5) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 54.5)-(95, 54.5) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 56.5)-(95, 56.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 58)-(95, 58) ', RGB(184, 227, 254), BF
    Printer.Line (5, 60)-(18, 60) ', RGB(184, 227, 254), BF
    ' orizzontali
    Printer.Line (42, 14.5)-(42, 20.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 14.5)-(5, 60) ', RGB(184, 227, 254), BF
    Printer.Line (18, 58)-(18, 60) ', RGB(184, 227, 254), BF
   ' Printer.Line (5, 12)-(5, 62)', RGB(184, 227, 254), BF
    Printer.Line (20, 20.5)-(20, 22.5) ', RGB(184, 227, 254), BF
    Printer.Line (58, 20.5)-(58, 52.5) ', RGB(184, 227, 254), BF
   ' Printer.Line (59.5, 12)-(59.5, 62)
    Printer.Line (62, 20.5)-(62, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (70, 20.5)-(70, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (65, 52.5)-(65, 58) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 20.5)-(84.5, 58) ', RGB(184, 227, 254), BF
    Printer.Line (95, 16.5)-(95, 58) ', RGB(184, 227, 254), BF
End Sub
Private Sub Command7_Click()
Dim fine, OK As Boolean
Dim impor As Double
Dim d1 As String, d2 As String, D3 As String, D4 As String, D5 As String, D6 As String, D7 As String, D8 As String, D11 As String, D21 As String, D31 As String
Dim i1 As String, I2 As String
Dim descrizione As String
Dim indi As String
Dim nota As String
Dim CDA As String
Dim codart As String
Dim Cas As String
Dim Prez As Double
Dim v_netto As Double
Dim Qta As Long
Dim Linea As Integer
Dim tipo_finmsg As Integer
Dim Msg, UMI As String
Dim Lpt As String
Dim V_IVA As Double
Dim v_totale As Double
Dim aliq As Single
Dim lung_sta As Integer
Dim colonna As Integer
Dim pag As Integer
Dim logo  As New StdPicture
Dim Appl As Object
Dim Doc As Object
  
     If CInt(copiuz.Text) = 0 Then GoTo Nfatt

If Stamp.ListIndex >= 0 Then
    Set Printer = Printers(Stamp.ListIndex)
    DB_STAMPANTI.Recordset.Edit
    DB_STAMPANTI.Recordset("IMPOSTATA") = Stamp.ListIndex
    DB_STAMPANTI.Recordset.Update
End If

If Contratto.Value = vbChecked Then
      Set Appl = CreateObject("Word.Application")
    'background dell'applicazione
      Appl.application.Visible = False
      On Error GoTo errato
      Set Doc = Appl.Documents.Open(App.Path & "\capitolato")
      Doc.FormFields("Data").Result = DATA.Text 'Adesso
      Appl.application.PrintOut
    'chiusura dell'applicazione e Doc
      Doc.CLOSE (False)
      Appl.quit
      Set Doc = Nothing
      Set Appl = Nothing
End If

' Con 12 caratteri per pollice
' [0..95] colonne
' [0..74] righe
'On Error Resume Next
Printer.ScaleMode = 4
'Printer.ScaleHeight = 330
'Printer.ScaleWidth = 217
Printer.PaperSize = 9
Printer.Copies = copiuz.Text
'Printer.ScaleMode = 6
Printer.FontTransparent = True
'Correctly sets the background mix mode to transparent
iBKMode = SetBkMode(Printer.hDC, TRANSPARENT)

If err.Number > 0 Then
    tipo_finmsg = 0
    Msg = "Impossibile eseguire la stampa." & Chr$(13)
    Msg = Msg & "Verificare che la stampante impostata sia quella corretta"
    If MsgBox(Msg, tipo_finmsg, "Stampa Preventivo") = 1 Then
    End If
Else
    If tutte.Value = 1 Then
        pag = 0
    Else
        pag = nump.Text
    End If
    attuale = 1
    fine = False
    DB_CLIENTI.DatabaseName = CurDir & "\SEA.mdb"
    DB_CLIENTI.RecordSource = "select * from db_clienti where codice = " & DB_STOPRE.Recordset("CODCLI")
    DB_CLIENTI.Refresh
    aliq = DB_STOPRE.Recordset("IVA")
    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
    DB_PREV.Refresh
While Not fine
    F_PREINS.Caption = "STAMPA DEL PREVENTIVO IN CORSO SI PREGA DI ATTENDERE"
    
' parte dedicata alla stampa del modello su foglio A4

If modulo.Value = vbUnchecked Then
  Set logo = LoadPicture(CurDir & "\logoP.bmp")
    Printer.PaintPicture logo, 1, 1, 37, 9
    
    
    Printer.FontName = "Arial"
    Printer.ForeColor = vbBlue 'RGB(184, 227, 254)
    Printer.FontSize = 7.5
    Printer.CurrentX = 55
    Printer.CurrentY = 2
    Lpt = "IMPIANTI ELETTRICI CIVILI INDUSTRIALI"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 3
    Lpt = "AUDIOVISIVI - SERVICE PER CONCERTI"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 4
    Lpt = "COMMERCIO MATERIALE ELETTRICO - TV ANTENNE - TELEFONIA"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 5
    Lpt = "DOMOTICA - AUTOMATISMI - RIVELAZIONE INCENDI "
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 6
    Lpt = "PARTITA IVA/CODICE FISCALE 0170798 034 6"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 7
    Lpt = "C.I.A.A. PR172901  ALBO ARTIGIANI 52134"
    Call Stampa(pag, Lpt)
    Printer.ForeColor = False
    
    dis_modello
    
    Printer.FontName = "Times New Roman"
    Printer.FontBold = True
    Printer.FontSize = 12
    Printer.CurrentX = 7
    Printer.CurrentY = 15
    Lpt = "PREVENTIVO  N."
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 18
    Printer.CurrentY = 17
    Lpt = "DEL :"
    Call Stampa(pag, Lpt)
    
    Printer.FontBold = False
    Printer.FontSize = 7
    Printer.CurrentX = 10
    Printer.CurrentY = 21.1
    Lpt = "CODICE"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 35
    Printer.CurrentY = 21.1
    Lpt = "DESCRIZIONE"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 59
    Printer.CurrentY = 21.1
    Lpt = "U.M."
    Call Stampa(pag, Lpt)
        
    Printer.CurrentX = 64
    Printer.CurrentY = 21.1
    Lpt = "QUANT."
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 72
    Printer.CurrentY = 21.1
    Lpt = "PREZZO UNITARIO"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 87
    Printer.CurrentY = 21.1
    Lpt = "IMPORTO"
    Call Stampa(pag, Lpt)
    
    Printer.FontSize = 9
    Printer.CurrentX = 76
    Printer.CurrentY = 53
    Lpt = "imponibile"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 7
    Printer.CurrentY = 53.5
    Lpt = "NOTE :"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 71
    Printer.CurrentY = 55
    Lpt = "IVA...........%"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 67
    Printer.CurrentY = 57
    Lpt = "TOTALE  DOCUMENTO"
    Call Stampa(pag, Lpt)
End If
' Fine Parte dedicata alla stampa del modello su foglio A4

        If Not IsNull(DB_CLIENTI.Recordset("NOME")) Then
         indi = DB_CLIENTI.Recordset("NOME")
          Else
            indi = ""
        End If
        i1 = dividi(indi, 39)
        indi = Right(indi, Len(indi) - Len(i1))
        I2 = dividi(indi, 39)
        indi = Right(indi, Len(indi) - Len(I2))
        i1 = Trim(i1)
        I2 = Trim(I2)
        Printer.FontBold = True
        Printer.FontSize = 12
        Printer.CurrentX = 52
        Printer.CurrentY = 10
        Call Stampa(pag, i1)
        If I2 <> "" Then
            Printer.CurrentX = 54
            Printer.CurrentY = 11
            Call Stampa(pag, I2)
        End If
  
    Printer.FontBold = False
    Printer.FontSize = 11
    Printer.CurrentX = 52
    Printer.CurrentY = 12
    Lpt = DB_CLIENTI.Recordset("VIA")
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 52
    Printer.CurrentY = 13
    Lpt = DB_CLIENTI.Recordset("CAP") & ", " & DB_CLIENTI.Recordset("CITTA") & " " & DB_CLIENTI.Recordset("PROVINCIA")
    Call Stampa(pag, Lpt)
  
  '  Printer.FontBold = True
    Printer.CurrentX = 52
    Printer.CurrentY = 17
    Lpt = "P.IVA/Cod.Fisc.: " & DB_CLIENTI.Recordset("PIVA") & " "
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 52
    Printer.CurrentY = 18
    Lpt = "Telefono: " & DB_CLIENTI.Recordset("TEL") & "  - Codice Cliente : " & DB_STOPRE.Recordset("codcli")
    Call Stampa(pag, Lpt)
      
    Printer.FontBold = True
    Printer.FontSize = 13
    Printer.CurrentX = 28
    Printer.CurrentY = 15
    Lpt = NORD.Text
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 28
    Printer.CurrentY = 17
    Lpt = DATA.Text
    Call Stampa(pag, Lpt)
    Linea = 23
   ' Printer.FontName = "Times New Roman"
    Printer.FontName = "Courier New"
    Printer.FontSize = 10
    Printer.FontBold = False
    
          If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
            nota = DB_STOPRE.Recordset("NOTE")
        Else
            nota = ""
        End If
        d1 = dividi(nota, 50)
        nota = Right(nota, Len(nota) - Len(d1))
        d2 = dividi(nota, 55)
        nota = Right(nota, Len(nota) - Len(d2))
        D3 = dividi(nota, 55)
        d1 = Trim(d1)
        d2 = Trim(d2)
        D3 = Trim(D3)
        Printer.CurrentX = 15
        Printer.CurrentY = 53
        Call Stampa(pag, d1)
        If d2 <> "" Then
            Printer.CurrentX = 10
            Printer.CurrentY = 55
            Call Stampa(pag, d2)
            If D3 <> "" Then
                Printer.CurrentX = 10
                Printer.CurrentY = 56.5
                Call Stampa(pag, D3)
            End If
        End If
    
    While Not DB_PREV.Recordset.EOF And Not Linea > 51
        codart = ""
        Casa = ""
        CDA = ""
        D11 = ""
        D21 = ""
        D31 = ""
        If Not IsNull(DB_PREV.Recordset("CASA")) Then
            Cas = DB_PREV.Recordset("CASA")
        End If
        
        If Not IsNull(DB_PREV.Recordset("CODICE")) Then
            codart = DB_PREV.Recordset("CODICE")
            CDA = Cas & " " & codart
        End If
        D11 = Mid(CDA, 1, 13)
        Printer.CurrentX = 7
        Printer.CurrentY = Linea
        Call Stampa(pag, D11)
        If Len(CDA) > 13 Then
            D21 = Mid(CDA, 14, 13)
            If Len(D21) > 13 Then
                D31 = Mid(CDA, 26, 13)
            End If
        End If
        If Not IsNull(DB_PREV.Recordset("DESCRIZIONE")) Then
            descrizione = DB_PREV.Recordset("DESCRIZIONE")
        Else
            descrizione = ""
        End If
        d1 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(d1))
        d2 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(d2))
        D3 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D3))
        D4 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D4))
        D5 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D5))
        D6 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D6))
        D7 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D7))
        D8 = dividi(descrizione, 36)
        d1 = Trim(d1)
        d2 = Trim(d2)
        D3 = Trim(D3)
        D4 = Trim(D4)
        D5 = Trim(D5)
        D6 = Trim(D6)
        D7 = Trim(D7)
        D8 = Trim(D8)
        
        Printer.CurrentX = 20
        Printer.CurrentY = Linea
        Call Stampa(pag, d1)
        
        If Not IsNull(DB_PREV.Recordset("UM")) Then
            UMIS = DB_PREV.Recordset("UM")
            Printer.CurrentX = 59
            Printer.CurrentY = Linea
            Call Stampa(pag, Um)
        End If
        
        If Not IsNull(DB_PREV.Recordset("QUANTITA")) Then
            Qta = DB_PREV.Recordset("QUANTITA")
            If Qta - Int(Qta) = 0 Then
                lung_sta = Len(Format(Qta, F_MENU.FormatoEuro))
                Printer.CurrentX = 68 - lung_sta
                Printer.CurrentY = Linea
                Call Stampa(pag, (Format(Qty, F_MENU.FormatoEuro)))
            Else
                lung_sta = Len(Format(Qty, F_MENU.FormatoEuro))
                Printer.CurrentX = 68 - lung_sta
                Printer.CurrentY = Linea
                Call Stampa(pag, Format(Qty, F_MENU.FormatoEuro))
            End If
        End If
        
        If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
            Prez = DB_PREV.Recordset("PREZZO")
            lung_sta = Len(Format(Prez, F_MENU.FormatoEuro))
            colonna = 81 - lung_sta
            Printer.CurrentX = colonna
            Printer.CurrentY = Linea
            Call Stampa(pag, Format(Prez, F_MENU.FormatoEuro))
        End If
        
        If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
            impor = DB_PREV.Recordset("IMPORTO")
            lung_sta = Len(Format(impor, F_MENU.FormatoEuro))
            colonna = 94 - lung_sta
            Printer.CurrentX = colonna
            Printer.CurrentY = Linea
            Call Stampa(pag, Format(impor, F_MENU.FormatoEuro))
        End If
        
        If d2 <> "" Or D21 <> "" Then
            Linea = Linea + 1
            If d2 <> "" Then
                Printer.CurrentX = 20
                Printer.CurrentY = Linea
                Call Stampa(pag, d2)
            End If
            If D21 <> "" Then
                Printer.CurrentX = 7
                Printer.CurrentY = Linea
                Call Stampa(pag, D21)
            End If
            If D3 <> "" Or D31 <> "" Then
                Linea = Linea + 1
                If D3 <> "" Then
                    Printer.CurrentX = 20
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D3)
                End If
                If D31 <> "" Then
                    Printer.CurrentX = 7
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D31)
                End If
                If D4 <> "" Then
                    Linea = Linea + 1
                    Printer.CurrentX = 20
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D4)
                    If D5 <> "" Then
                        Linea = Linea + 1
                        Printer.CurrentX = 20
                        Printer.CurrentY = Linea
                        Call Stampa(pag, D5)
                        If D6 <> "" Then
                            Linea = Linea + 1
                            Printer.CurrentX = 20
                            Printer.CurrentY = Linea
                            Call Stampa(pag, D6)
                            If D7 <> "" Then
                                Linea = Linea + 1
                                Printer.CurrentX = 20
                                Printer.CurrentY = Linea
                                Call Stampa(pag, D7)
                                If D8 <> "" Then
                                    Linea = Linea + 1
                                    Printer.CurrentX = 20
                                    Printer.CurrentY = Linea
                                    Call Stampa(pag, D8)
                                End If
                            End If
                       End If
                    End If
                End If
            End If
        End If
        Linea = Linea + 1
        DB_PREV.Recordset.MoveNext
    Wend
    If DB_PREV.Recordset.EOF Then
        fine = True
        Printer.CurrentX = 75
        Printer.CurrentY = 55
        Lpt = CStr(aliq)
        Call Stampa(pag, Lpt)
          
    ' Da cambiare quando la valuta sarà in EURO
        Netto (aliq)
      '  S_IVA (aliq)
        v_netto = t_netto
        
        lung_sta = Len(Format(v_netto, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 53
        Call Stampa(pag, Format(v_netto, F_MENU.FormatoEuro))
        
        V_IVA = T_IVA
        lung_sta = Len(Format(V_IVA, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 55
        Call Stampa(pag, Format(V_IVA, F_MENU.FormatoEuro))
        
        v_totale = v_netto + V_IVA
        lung_sta = Len(Format(v_totale, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 57
        Call Stampa(pag, Format(v_totale, F_MENU.FormatoEuro))
              
        Printer.CurrentX = 7
        Printer.CurrentY = 59
        Lpt = "Pagina " & attuale
        Call Stampa(pag, Lpt)
        
        Printer.EndDoc
    Else
        Printer.CurrentX = 7
        Printer.CurrentY = 59
        Lpt = "Pagina " & attuale
        Call Stampa(pag, Lpt)
        
        Printer.CurrentX = 89
        Printer.CurrentY = 57
        Call Stampa(pag, "Segue")
        If pag = 0 Then
            Printer.NewPage
            attuale = attuale + 1
        Else
            attuale = attuale + 1
        End If
    End If
Wend

F_PREINS.Caption = "Creazione Preventivi"
End If
On Error GoTo 0
st.Visible = False
Call riordino
'Call Calcoli
copiuz.Text = 0
Stamp.Clear
Exit Sub
Nfatt: MsgBox "Devi dirmi Quante Copie Ne Vuoi!!!!", vbExclamation
Exit Sub
errato: MsgBox "il documento citato non e presente oppure presenta un nome errato  il nome corretto è 'Capitolato' ", vbExclamation
Resume Next
Resume
End Sub


Private Sub Command8_Click()
    Variazione.Visible = False
End Sub

Private Sub Command9_Click()
Dim Ric As Single
    Variazione.Visible = False
    If var.Text <> "" Then
        DB_PREV.Refresh
        salva = True
        While Not DB_PREV.Recordset.EOF
            If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
                Ric = DB_PREV.Recordset("PREZZO") * var.Text / 100
                DB_PREV.Recordset.Edit
                DB_PREV.Recordset("PREZZO") = Format((DB_PREV.Recordset("PREZZOI") - Ric), F_MENU.FormatoEuro)
      '        On Error Resume Next
                DB_PREV.Recordset("IMPORTO") = Format((DB_PREV.Recordset("PREZZO") * DB_PREV.Recordset("QUANTITA")), F_MENU.FormatoEuro)
                DB_PREV.Recordset("SCONTO") = Format(var.Text, F_MENU.FormatoEuro)
                DB_PREV.Recordset.Update
            End If
            DB_PREV.Recordset.MoveNext
        Wend
        salva = False
        Me.Timer1.Enabled = True
        
    End If
End Sub

Private Sub DB_prev_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Netto(V_IVA As Double)
    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
    DB_PREV.Refresh
    t_netto = "0"
    T_IVA = "0"
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
            t_netto = t_netto + DB_PREV.Recordset("IMPORTO")
        End If
    DB_PREV.Recordset.MoveNext
    Wend
    T_IVA = t_netto * V_IVA / 100
End Sub
'Private Sub S_IVA(V_IVA As Currency)
'    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
'    DB_PREV.Refresh
'       T_IVA = "0"
'        T_IVA = t_netto * V_IVA / 100
'End Sub

Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
    If Chr(KeyAscii) = "g" Or Chr(KeyAscii) = "G" Then DBGrid1.Height = 8500
    If Chr(KeyAscii) = "p" Or Chr(KeyAscii) = "P" Then DBGrid1.Height = 2616
End Sub

Private Sub Form_Activate()
    flag = True
   ' Call Calcoli
    If BT_elart.Visible = False Then
       '  Call Calcoli
        DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
        DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
        DB_PREV.Refresh
        Call Calcoli
        flag = False
    
    End If
    DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
    DB_STOPRE.Refresh
    DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
    DB_EURO.RecordSource = "db_EURO"
    DB_EURO.Refresh

' If L_DocP.Visible Then
'   Call riordino
  '  Else
'    Call Calcoli
    Call riordino
  ' End If
    
    
'   salva = False

    
   ' DBGrid1.Columns(0).Visible = False
    'DBGrid1.Columns(1).Visible = False
    'DBGrid1.Columns(2).Width = 620
   ' DBGrid1.Columns(2).Alignment = 2
   ' DBGrid1.Columns(3).Width = 620
   ' DBGrid1.Columns(3).Alignment = 2
   ' DBGrid1.Columns(4).Width = 920
   ' DBGrid1.Columns(4).Alignment = 2
   ' DBGrid1.Columns(5).Width = 4700
   ' DBGrid1.Columns(6).Width = 500
   ' DBGrid1.Columns(6).Alignment = 2
   ' DBGrid1.Columns(7).Width = 723
   ' DBGrid1.Columns(7).Alignment = 2
   ' DBGrid1.Columns(8).Width = 680
   ' DBGrid1.Columns(9).Width = 680
   ' DBGrid1.Columns(10).Width = 680
   ' DBGrid1.Columns(11).Width = 680
   ' DBGrid1.Columns(12).Width = 680
   ' DBGrid1.Columns(13).Width = 680
   ' DBGrid1.Columns(14).Width = 550
   ' DBGrid1.Columns(15).Width = 550
   ' DBGrid1.Columns(16).Width = 680
End Sub

Private Sub Form_Deactivate()
Dim IMPO, IVA, parz As Double
    IMPO = 0
    DB_PREV.Refresh
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("PREZZO")) And Not IsNull(DB_PREV.Recordset("QUANTITA")) And Not IsNull(DB_PREV.Recordset("IVA")) Then
            IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
        End If
        DB_PREV.Recordset.MoveNext
    Wend
    DB_STOPRE.Recordset.Edit
    DB_STOPRE.Recordset("IMPONIBILE") = Format(IMPO, F_MENU.FormatoEuro)
    DB_STOPRE.Recordset.Update
  
End Sub


Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
    X = (Screen.Width - 11400) / 2
    Y = (Screen.Height - 8004) / 2
    F_PREINS.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub
Private Sub Form_Unload(Cancel As Integer)
    Call Form_Deactivate
    End
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        IVA.SetFocus
    End If
End Sub

Private Sub MANOD_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If MANOD.Text <> "" And Not IsNumeric(MANOD.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        MANOD.SetFocus
    End If
   End Sub
  
Private Sub mnuesci_Click()
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_MENU.Show
End Sub

Private Sub mnuins_Click()
    F_MENU.DATA.Text = Date
    F_MENU.DB_STOPRE.DatabaseName = CurDir & "\SEA.mdb"
    F_MENU.DB_STOPRE.RecordSource = "select * from db_stopre order by numero"
    F_MENU.DB_STOPRE.Refresh
    If Not F_MENU.DB_STOPRE.Recordset.EOF Then
        F_MENU.DB_STOPRE.Recordset.MoveLast
        F_MENU.NORD.Text = DB_STOPRE.Recordset("numero") + 1
    Else
        F_MENU.NORD.Text = 1
    End If
    F_MENU.Prev.Visible = True
    F_MENU.NORD.Visible = True
    F_MENU.dat.Visible = True
    F_MENU.DATA.Visible = True
    F_MENU.num.Visible = True
    F_MENU.V_IVA.Visible = True
    F_MENU.IVA.Visible = True
    F_MENU.BtIns.Visible = True
    F_MENU.Btann.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_MENU.Show
End Sub

Private Sub mnuric_Click()
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_STOPRE.Show
End Sub

Private Sub nump_Change()
     If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub nump_GotFocus()
    If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub Prscont_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prscont.Text <> "" And Not IsNumeric(Prscont.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Prscont.SetFocus
    End If
End Sub

Private Sub Prunit_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prunit.Text <> "" And Not IsNumeric(Prunit.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Prunit.SetFocus
    End If
    If Prunit.Text <> "" And IsNumeric(Prunit.Text) Then
        Sconto.Text = 0
        Prscont.Text = Prunit.Text
        IVA.Text = DB_STOPRE.Recordset("IVA")
    End If
End Sub


Private Sub Qty_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Qty.Text <> "" And Not IsNumeric(Qty.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Qty.SetFocus
    End If
End Sub


Private Sub r_Click()
F_PREINS.Hide
F_STOPRE.Show
F_STOPRE.Codice_Cliente.Visible = True
'Call F_STOPRE.ordCli_Click

'DB_STOPRE.RecordSource = "select * from db_stopre where codcli=" & F_STOPRE.cliente.Text
'         DB_STOPRE.Refresh
'            If DB_STOPRE.Recordset.EOF Then
               ' Call messaggio
'           End If
'Call riord

End Sub

Private Sub Sconto_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
Dim sc As Currency
    If Sconto.Text <> "" And Not IsNumeric(Sconto.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Sconto.SetFocus
    Else
    If Sconto.Text <> "" And Prunit <> "" Then
        sc = Prunit.Text * Sconto.Text / 100
        Prscont = Prunit - sc
    End If
    End If
End Sub

Private Sub Timer1_Timer()
Form_Activate
'Call Calcoli
Me.Timer1.Enabled = False
End Sub

Private Sub tutte_Click()
    If tutte.Value = 1 Then
        nump.Text = ""
    End If
End Sub

Private Sub UM_LostFocus()
    Um.Text = UCase(Um.Text)
End Sub

Private Sub Var_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If var.Text <> "" And Not IsNumeric(var.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        var.SetFocus
    End If
End Sub


questo e il codice dove prelevo l'articolo

Option Compare Text
Dim flag, flag1 As Boolean
Dim pos_db, cont, pos_ric As Integer
Dim salva As Boolean

Private Sub BT_CANCELLA_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
    If Not DB_ARTICOLI.Recordset.EOF Then
        tipo_finmsg = 4
        Msg = "Conferma la Cancellazione dei dati di" & Chr$(13)
        Msg = Msg & DB_ARTICOLI.Recordset("CASA") & " " & DB_ARTICOLI.Recordset("CODICE") & " ?"
        If MsgBox(Msg, tipo_finmsg, "Cancella Dati Articolo") = 6 Then
            salva = True
            DB_ARTICOLI.Recordset.Delete
            salva = False
            DB_ARTICOLI.Recordset.MoveNext
            If DB_ARTICOLI.Recordset.EOF Then
                DB_ARTICOLI.Refresh
                If Not DB_ARTICOLI.Recordset.EOF Then DB_ARTICOLI.Recordset.MoveLast
            End If
            flag = False
            flag1 = False
            ric_casa.Text = ""
            Ric_cod.Text = ""
            ric_des.Text = ""
            flag = True
            flag1 = True
            DB_ART.Refresh
        End If
    End If
End Sub

Private Sub BT_pann_Click()
    BT_pins.Visible = False
    BT_pann.Visible = False
    BT_REGMOD.Visible = True
    BT_CANCELLA.Visible = True
    mnuart.Enabled = True
    mnumenu.Enabled = True
    F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
    If L_DocP.Visible Then
        F_ARTRMO.Hide
        F_PREINS.Show
    End If
    If L_DocB.Visible Then
        F_ARTRMO.Hide
        F_BOLINS.Show
    End If
    If L_DocF.Visible Then
        F_ARTRMO.Hide
        F_FATINS.Show
    End If
    If L_DocR.Visible Then
        F_ARTRMO.Hide
        F_RICINS.Show
    End If
    L_DocF.Visible = False
    L_DocP.Visible = False
    L_DocB.Visible = False
    L_DocR.Visible = False
End Sub

Private Sub BT_pins_Click()
If Not DB_ARTICOLI.Recordset.EOF Then
    BT_pins.Visible = False
    BT_pann.Visible = False
    BT_REGMOD.Visible = True
    BT_CANCELLA.Visible = True
    mnuart.Enabled = True
    mnumenu.Enabled = True
    F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
    If L_cantieri.Visible Then
    With F_CANTINS
        .DB_CANT.DatabaseName = CurDir & "\SEA.mdb"
        .DB_CANT.RecordSource = "select * from db_cant where CANT = " & .NORD.Text & " and com = " & .com.Text
        .DB_CANT.Refresh
        If Not .DB_CANT.Recordset.EOF Then
            .DB_CANT.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .C0.Visible = True
        .R0.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_CANTINS.Show
    End If
    If L_DocP.Visible Then
    With F_PREINS
        .DB_PREV.DatabaseName = CurDir & "\SEA.mdb"
        .DB_PREV.RecordSource = "select * from db_Prev where numero =" & .NORD.Text '& " order by ID"
        .DB_PREV.Refresh
        If Not .DB_PREV.Recordset.EOF Then
            .DB_PREV.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_PREINS.Show
    End If
    If L_DocF.Visible Then
    With F_FATINS
        .DB_FATTURE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_FATTURE.RecordSource = "select * from db_fatture where numero = " & .NORD.Text '& "order By ID"
        .DB_FATTURE.Refresh
        If Not .DB_FATTURE.Recordset.EOF Then
            .DB_FATTURE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_FATINS.Show
    End If
    If L_DocFele.Visible Then
    With F_FATTELE
        .DB_FATTELE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_FATTELE.RecordSource = "select * from db_fattele where numero = " & .NORD.Text '& "order By ID"
        .DB_FATTELE.Refresh
        If Not .DB_FATTELE.Recordset.EOF Then
            .DB_FATTELE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_FATTELE.Show
    End If
    If L_DocB.Visible Then
    With F_BOLINS
        .DB_BOLLE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_BOLLE.RecordSource = "select * from db_BOLLE where numero = " & .NORD.Text '& "order by ID"
        .DB_BOLLE.Refresh
        If Not .DB_BOLLE.Recordset.EOF Then
            .DB_BOLLE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_BOLINS.Show
    End If
If L_DocR.Visible Then
    With F_RICINS
        .DB_RICEVUTE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_RICEVUTE.RecordSource = "select * from db_ricevute where numero = " & .NORD.Text
        .DB_RICEVUTE.Refresh
        If Not .DB_RICEVUTE.Recordset.EOF Then
            .DB_RICEVUTE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_RICINS.Show
    End If
    L_DocF.Visible = False
    L_DocP.Visible = False
    L_DocB.Visible = False
    L_DocR.Visible = False
    L_cantieri.Visible = False
End If
End Sub

Private Sub BT_REGMOD_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
Dim esegui As Boolean
Dim pos As Integer
If Not DB_ARTICOLI.Recordset.EOF Then
    esegui = True
    pos = DB_ARTICOLI.Recordset.AbsolutePosition
    DB_ART.Refresh
    While (Not DB_ART.Recordset.EOF) And esegui
        If DB_ART.Recordset("CASA") = Casa.Text And DB_ART.Recordset("CODICE") = Codice.Text And DB_ART.Recordset.AbsolutePosition <> pos Then
            esegui = False
        Else
            DB_ART.Recordset.MoveNext
        End If
    Wend
    If esegui Then
        salva = True
        DB_ARTICOLI.Recordset.Edit
        If Prezzo.Text <> "" And Ricarico.Text <> "" Then
            If DB_ARTICOLI.Recordset("COSTO") <> Prezzo.Text Or DB_ARTICOLI.Recordset("Ricarico") <> Ricarico.Text Or DB_ARTICOLI.Recordset("iva") <> IVA.Text Then
                DB_ARTICOLI.Recordset("data") = Date
            End If
            DB_ARTICOLI.Recordset("LISTINO") = Format((Prezzo.Text + (Prezzo.Text * Ricarico.Text / 100)), F_MENU.FormatoEuro)
            DB_ARTICOLI.Recordset("TOTIVA") = Format(((DB_ARTICOLI.Recordset("LISTINO") * DB_ARTICOLI.Recordset("IVA") / 100)), F_MENU.FormatoEuro)
            DB_ARTICOLI.Recordset("Totale") = Format((DB_ARTICOLI.Recordset("LISTINO") + (DB_ARTICOLI.Recordset("TOTIVA"))), F_MENU.FormatoEuro)
        End If
        DB_ARTICOLI.Recordset.Update
        salva = False
    Else
        tipo_finmsg = 0
        Msg = "Il Codice della casa " & DB_ARTICOLI.Recordset("CASA") & " è già esistente."
        Msg = Msg & " La modifica non può essere registrata"
        If MsgBox(Msg, tipo_finmsg, "Modifica Dati Articoli") = 1 Then
            Casa.SetFocus
        End If
    End If
End If
End Sub

Private Sub BT_RIC_Click()
Dim pos_str, tipo_finmsg As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
If Not DB_ARTICOLI.Recordset.EOF Then
If ric_des.Text <> "" Then
    trovato = False
    pos_db = DB_ARTICOLI.Recordset.AbsolutePosition
    cont = 1
    While cont < 3 And Not trovato
        While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
            var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
            pos_str = InStr(var_db, ric_des.Text)
            If pos_str > 0 Then
                trovato = True
            Else
                DB_ARTICOLI.Recordset.MoveNext
                If DB_ARTICOLI.Recordset.AbsolutePosition = pos_db Then
                    cont = 3
                End If
            End If
        Wend
        If DB_ARTICOLI.Recordset.EOF Then
            DB_ARTICOLI.Refresh
            cont = cont + 1
        End If
    Wend
    If Not trovato Then
        tipo_finmsg = 0
        Msg = "ATTENZIONE: La parola non è presente in elenco"
        If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
            ric_des.SetFocus
        End If
    Else
        BT_RIC.Visible = False
        succ.Visible = True
        BT_stop.Visible = True
        ric_des.Locked = True
    End If
End If
End If
End Sub

Private Sub BT_STOP_Click()
    BT_stop.Visible = False
    succ.Visible = False
    BT_RIC.Visible = True
    ric_des.Locked = False
End Sub

Private Sub carsca_Click()
    F_ARTRMO.Hide
    F_ARTINV.Show
End Sub

Private Sub Casa_LostFocus()
    Casa.Text = UCase(Casa.Text)
End Sub
Private Sub codice_LostFocus()
    Codice.Text = UCase(Codice.Text)
End Sub
Private Sub DB_ARTICOLI_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Form_Activate()
Dim sdir As String
    sdir = CurDir
    DB_ARTICOLI.DatabaseName = sdir & "\sea.mdb"
    DB_ARTICOLI.RecordSource = "select * from db_articoli order by casa,codice"
    DB_ARTICOLI.Refresh
    DB_ART.DatabaseName = sdir & "\sea.mdb"
    DB_ART.RecordSource = "select * from db_articoli order by casa,codice"
    DB_ART.Refresh
    
    
    DBGrid1.Columns(0).Width = 500
    DBGrid1.Columns(0).Alignment = 0
    DBGrid1.Columns(1).Width = 920
    DBGrid1.Columns(1).Alignment = 0
    DBGrid1.Columns(2).Width = 3500
    DBGrid1.Columns(2).Alignment = 0
    DBGrid1.Columns(3).Width = 380
    DBGrid1.Columns(3).Alignment = 2
    DBGrid1.Columns(4).Width = 870
    DBGrid1.Columns(4).Alignment = 0
    DBGrid1.Columns(5).Width = 750
    DBGrid1.Columns(5).Alignment = 0
    DBGrid1.Columns(6).Width = 750
    DBGrid1.Columns(6).Alignment = 0
    DBGrid1.Columns(7).Width = 750
    DBGrid1.Columns(7).Alignment = 0
    DBGrid1.Columns(8).Width = 750
    DBGrid1.Columns(8).Alignment = 0
    DBGrid1.Columns(9).Width = 700
    DBGrid1.Columns(9).Alignment = 0
    DBGrid1.Columns(10).Width = 750
    DBGrid1.Columns(10).Alignment = 2
    DBGrid1.Columns(11).Width = 750
    DBGrid1.Columns(11).Alignment = 0
    DBGrid1.Columns(12).Width = 750
    DBGrid1.Columns(12).Alignment = 0
    DBGrid1.Columns(13).Width = 750
    DBGrid1.Columns(13).Alignment = 0
    DBGrid1.Columns(14).Width = 1000
    DBGrid1.Columns(14).Alignment = 0
    
    DBGrid1.SetFocus
    salva = False
    flag = False
    flag1 = True
    ric_casa = ""
    Ric_cod = ""
    ric_des = ""
    flag = True
    flag1 = True
    BT_stop.Visible = False
    succ.Visible = False
    BT_RIC.Visible = True
    ric_des.Locked = False
End Sub

Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
    X = (Screen.Width - 11400) / 2
    Y = (Screen.Height - 8004) / 2
    F_ARTRMO.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub

Private Sub Form_Unload(Cancel As Integer)
    End
End Sub

Private Sub Giacenza_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Giacenza.Text <> "" And Not IsNumeric(Giacenza.Text) Then
        tipo_finmsg = 0
        Msg = "La giacenza non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Giacenza.SetFocus
    End If
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
        tipo_finmsg = 0
        Msg = "L'IVA non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        IVA.SetFocus
    End If
End Sub

Private Sub list_Click()
    F_ARTRMO.Hide
    F_ARTAGG.Show
End Sub

Private Sub mnuesci_Click()
    F_ARTRMO.Hide
    F_MENU.Show
End Sub

Private Sub mnuins_Click()
    F_ARTRMO.Hide
    F_ARTINS.Show
End Sub

Private Sub modtut_Click()
    F_ARTRMO.Hide
    F_ARTMTU.Show
End Sub

Private Sub Prezzo_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prezzo.Text <> "" And Not IsNumeric(Prezzo.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Prezzo.SetFocus
    End If
End Sub

Private Sub ric_casa_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung As Integer
If flag1 Then
    flag = False
    Ric_cod.Text = ""
    flag = True
    DB_ARTICOLI.Refresh
    var_ins = ric_casa.Text
    lung = Len(var_ins)
    While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
        var_db = DB_ARTICOLI.Recordset("CASA")
        var_db = Left(var_db, lung)
        If var_db = var_ins Then
            trovato = True
            ric_casa.SetFocus
        Else
            DB_ARTICOLI.Recordset.MoveNext
        End If
    Wend
    If DB_ARTICOLI.Recordset.EOF Then
         DB_ARTICOLI.Refresh
         ric_casa.SetFocus
    End If
    pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
End If
End Sub

Private Sub ric_cod_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung, pos, I As Integer
If flag Then
    var_ins = Ric_cod.Text
    If ric_casa = "" Then
        DB_ARTICOLI.Refresh
        pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
    End If
    lung = Len(var_ins)
    While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
        If Ric_cod = "" Then
            DB_ARTICOLI.Refresh
            For I = 1 To pos_ric
                DB_ARTICOLI.Recordset.MoveNext
            Next I
            Ric_cod.SetFocus
        End If
        var_db = DB_ARTICOLI.Recordset("CODICE")
        var_db = Left(var_db, lung)
        If var_db = var_ins Then
            trovato = True
            Ric_cod.SetFocus
        Else
            DB_ARTICOLI.Recordset.MoveNext
        End If
    Wend
    If DB_ARTICOLI.Recordset.EOF Then
         If ric_casa = "" Then
            DB_ARTICOLI.Refresh
            Ric_cod.SetFocus
         Else
            DB_ARTICOLI.Refresh
            For I = 1 To pos_ric
                DB_ARTICOLI.Recordset.MoveNext
            Next I
            Ric_cod.SetFocus
         End If
    End If
End If
End Sub

Private Sub Ricarico_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Ricarico.Text <> "" And Not IsNumeric(Ricarico.Text) Then
        tipo_finmsg = 0
        Msg = "Il ricarico non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Ricarico.SetFocus
    End If
End Sub

Private Sub sta_Click()
    F_ARTRMO.Hide
    F_ARTSTA.Show
End Sub

Private Sub succ_Click()
Dim pos_str, tipo_finmsg, I As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
    trovato = False
    If Not (DB_ARTICOLI.Recordset.AbsolutePosition = 1 And cont = 2) Then
        DB_ARTICOLI.Recordset.MoveNext
    End If
    While cont < 3 And Not trovato
        While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
            If DB_ARTICOLI.Recordset.AbsolutePosition >= pos_db And cont = 2 Then
                cont = 3
            End If
            var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
            pos_str = InStr(var_db, ric_des.Text)
            If pos_str > 0 Then
                trovato = True
            Else
                DB_ARTICOLI.Recordset.MoveNext
            End If
        Wend
        If DB_ARTICOLI.Recordset.EOF Then
            DB_ARTICOLI.Refresh
            cont = cont + 1
        End If
    Wend
    If cont >= 3 Then
        tipo_finmsg = 0
        Msg = "ATTENZIONE: Tutte le occorrenze della parola sono state trovate"
        If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
            ric_des.SetFocus
            BT_stop.Visible = False
            succ.Visible = False
            BT_RIC.Visible = True
            ric_des.Locked = False
        End If
    End If
End Sub



spero qualcuno mi possa riuscire a dare una mano grazie a tutti comunque per la cortesia e la
celerita delle risposte




PM Quote
Avatar
nessuno (Normal User)
Guru^2


Messaggi: 6403
Iscritto: 03/01/2010

Segnala al moderatore
Postato alle 19:36
Domenica, 26/06/2022
Intanto il codice va riportato tra tag code o non si capisce nulla.

E poi dovresti dire di quale chiamata e sub stai parlando. O ce lo inventiamo?

A che serve tutto quel (pessimo) codice se il problema non dici dove sta?

Ultima modifica effettuata da nessuno il 26/06/2022 alle 19:52


Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
PM Quote
Avatar
islington (Normal User)
Newbie


Messaggi: 8
Iscritto: 26/06/2022

Segnala al moderatore
Postato alle 23:52
Domenica, 26/06/2022
ciao scusami, non volevo offenderti, io i tag li ho messi
se mi dici cos' non so perche non li ha presi
provero a rimetterli

la chiamata che rompe le scatole è
Codice sorgente - presumibilmente Visual Basic 6

  1. call calcoli




Codice sorgente - presumibilmente VB.NET

  1. Option Compare Text
  2. Dim salva As Boolean
  3. Dim flag As Boolean
  4. Dim T_IVA As Double, t_netto As Double
  5. Dim attuale As Integer
  6. #If Win32 Then
  7.  
  8.       Private Declare Function SetBkMode Lib "gdi32" _
  9.       (ByVal hDC As Long, ByVal nBkMode As Long) As Long
  10.  
  11.       Private iBKMode As Long
  12.  
  13.    #Else
  14.  
  15.       Private Declare Function SetBkMode Lib "GDI" (ByVal hDC As Integer _
  16.        , ByVal nBkMode As Integer) As Integer
  17.  
  18.       Private iBKMode As Integer
  19.  
  20.    #End If
  21.  
  22.       Private Const TRANSPARENT = 1
  23.       Private Const OPAQUE = 2
  24. Public Sub riordino()
  25.    
  26.    ' DB_PREV.Refresh
  27.    ' DB_PREV.Recordset.MoveLast
  28.  
  29.     DBGrid1.Columns(0).Visible = False
  30.     DBGrid1.Columns(1).Visible = False
  31.     DBGrid1.Columns(2).Visible = False
  32.     DBGrid1.Columns(3).Width = 720
  33.     DBGrid1.Columns(3).Alignment = 2
  34.     DBGrid1.Columns(4).Width = 1120
  35.     DBGrid1.Columns(4).Alignment = 2
  36.     DBGrid1.Columns(5).Width = 5900
  37.     DBGrid1.Columns(6).Width = 600
  38.     DBGrid1.Columns(6).Alignment = 2
  39.     DBGrid1.Columns(7).Width = 1100
  40.     DBGrid1.Columns(7).Alignment = 2
  41.     DBGrid1.Columns(8).Width = 1000
  42.     DBGrid1.Columns(9).Width = 1000
  43.     DBGrid1.Columns(10).Width = 1000
  44.     DBGrid1.Columns(11).Width = 1000
  45.     DBGrid1.Columns(12).Width = 1000
  46.     DBGrid1.Columns(13).Width = 1000
  47.     DBGrid1.Columns(14).Width = 1000
  48.     DBGrid1.Columns(15).Width = 700
  49.     DBGrid1.Columns(16).Width = 1000
  50. '    DBGrid1.SetFocus
  51.  
  52.  
  53. End Sub
  54. Function dividi(descr As String, l As Integer) As String
  55. Dim cont As Integer
  56. Dim lung As Integer
  57. Dim spazio As String
  58.     ' Lunghezza stringa restituita
  59.     lung = l
  60.     If Len(descr) <= lung Then
  61.         dividi = descr
  62.     Else
  63.         cont = lung
  64.         spazio = Mid(descr, lung, 1)
  65.         While Not spazio = " "
  66.             cont = cont - 1
  67.             spazio = Mid(descr, cont, 1)
  68.         Wend
  69.         dividi = Mid(descr, 1, cont)
  70.     End If
  71. End Function
  72.  
  73. Private Sub CANCELLA()
  74.     Des.Text = ""
  75.     Um.Text = ""
  76.     Prunit.Text = ""
  77.     Prscont.Text = ""
  78.     Sconto.Text = ""
  79.     IVA.Text = ""
  80.     L9.Visible = False
  81.     L10.Visible = False
  82.     Costo.Visible = False
  83.     Ricarico.Visible = False
  84. End Sub
  85.  
  86. Private Sub Stampa(pagina As Integer, stringa As String)
  87.     If pagina = 0 Or pagina = attuale Then
  88.         Printer.Print stringa
  89.     End If
  90. End Sub
  91.  
  92. Private Sub Bt_addnota_Click()
  93.     If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
  94.         Note.Text = DB_STOPRE.Recordset("NOTE")
  95.     Else
  96.         Note.Text = ""
  97.     End If
  98.     Note.Visible = True
  99.     L_note.Visible = True
  100.     BT_insnota.Visible = True
  101.     Bt_annota.Visible = True
  102.     BT_parz.Visible = False
  103.     BT_forn.Visible = False
  104.     BT_var.Visible = False
  105.     Note.SetFocus
  106.     Bt_addnota.Visible = False
  107.     Call riordino
  108.     'Call Calcoli
  109. End Sub
  110.  
  111.  
  112. Private Sub BT_AnNota_Click()
  113.     Note.Visible = False
  114.     L_note.Visible = False
  115.     BT_insnota.Visible = False
  116.     Bt_annota.Visible = False
  117.     BT_parz.Visible = True
  118.     BT_var.Visible = True
  119.     Bt_addnota.Visible = True
  120.     BT_forn.Visible = True
  121.     DBGrid1.SetFocus
  122.     Call riordino
  123.     'Call Calcoli
  124. End Sub
  125.  
  126. Private Sub BT_annvoce_Click()
  127.     BT_var.Visible = True
  128.     Bt_addnota.Visible = True
  129.     BT_parz.Visible = True
  130.     BT_newvoce.Visible = True
  131.     BT_elart.Visible = False
  132.     L9.Visible = False
  133.     L10.Visible = False
  134.     Costo.Visible = False
  135.     Ricarico.Visible = False
  136.     BT_modvoce.Visible = True
  137.     BT_cancvoce.Visible = True
  138.     BT_insvoce.Visible = False
  139.     BT_sta.Visible = True
  140.     scelta.Visible = False
  141.     BT_annvoce.Visible = False
  142.     BT_forn.Visible = True
  143.     flag = False
  144.     DB_PREV.Recordset.MoveLast
  145.     DB_PREV.Recordset.Delete
  146.     DB_PREV.Recordset.MoveLast
  147.     DBGrid1.SetFocus
  148.     Call riordino
  149.     'Call Calcoli
  150. End Sub
  151.  
  152. Private Sub Bt_cancVoce_Click()
  153. Dim Msg As String
  154. Dim tipo_finmsg As Integer
  155.     If Not DB_PREV.Recordset.EOF Then
  156.         tipo_finmsg = 4
  157.         Msg = "Conferma la Cancellazione della voce dal documento ?"
  158.         If MsgBox(Msg, tipo_finmsg, "Cancella da Documento") = 6 Then
  159.             DB_PREV.Recordset.Delete
  160.             DB_PREV.Recordset.MoveNext
  161.             If DB_PREV.Recordset.EOF Then
  162.                 DB_PREV.Refresh
  163.                 If Not DB_PREV.Recordset.EOF Then DB_PREV.Recordset.MoveLast
  164.             End If
  165.             DBGrid1.SetFocus
  166.            ' Me.Timer1.Enabled = True
  167.            Call Calcoli
  168.         Call riordino
  169.          
  170.         End If
  171.     End If
  172.     'Call riordino
  173.     'Call Calcoli
  174. End Sub
  175.  
  176. Private Sub BT_elart_Click()
  177.     scelta.ZOrder 0
  178.     scelta.Visible = True
  179. End Sub
  180.  
  181. Private Sub BT_forn_Click()
  182.     F_CAMFOR.cliente = DB_STOPRE.Recordset("CLIENTE")
  183.     F_CAMFOR.NORD = NORD.Text
  184.     F_CAMFOR.DATA = DATA.Text
  185.     F_PREINS.Hide
  186.     F_CAMFOR.Show
  187. End Sub
  188.  
  189. Private Sub BT_insnota_Click()
  190.     DB_STOPRE.Recordset.Edit
  191.     DB_STOPRE.Recordset("NOTE") = Note.Text
  192.     DB_STOPRE.Recordset.Update
  193.     Note.Visible = False
  194.     L_note.Visible = False
  195.     BT_insnota.Visible = False
  196.     Bt_annota.Visible = False
  197.     BT_parz.Visible = True
  198.     BT_var.Visible = True
  199.     BT_forn.Visible = True
  200.     Bt_addnota.Visible = True
  201.     DBGrid1.SetFocus
  202. End Sub
  203.  
  204. Private Sub BT_insvoce_Click()
  205.     IVA.Text = DB_STOPRE.Recordset("IVA")
  206.     salva = True
  207.     DB_PREV.Recordset.Edit
  208.     DB_PREV.Recordset("NUMERO") = NORD.Text
  209.     If Qty.Text <> "" And Prscont.Text <> "" Then
  210.         DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
  211.         End If
  212.      If Qty.Text <> "" And UDC.Text <> "" Then
  213.          DB_PREV.Recordset("Tot_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
  214.           End If
  215.         If Qty.Text <> "" And MANOD.Text <> "" Then
  216.          DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
  217.           End If
  218.          
  219.     DB_PREV.Recordset.Update
  220.     salva = False
  221.     BT_var.Visible = True
  222.     Bt_addnota.Visible = True
  223.     BT_parz.Visible = True
  224.     BT_sta.Visible = True
  225.     BT_newvoce.Visible = True
  226.     BT_modvoce.Visible = True
  227.     BT_cancvoce.Visible = True
  228.     BT_elart.Visible = False
  229.     scelta.Visible = False
  230.     L9.Visible = False
  231.     L10.Visible = False
  232.     Costo.Visible = False
  233.     Ricarico.Visible = False
  234.     BT_insvoce.Visible = False
  235.     BT_annvoce.Visible = False
  236.     BT_forn.Visible = True
  237.     DB_PREV.Recordset.MoveLast
  238.     DBGrid1.SetFocus
  239.     flag = False
  240.    
  241.     Call Calcoli
  242.    Call riordino
  243.    
  244.    ' DBGrid1.SetFocus
  245.         End Sub
  246.  
  247.  
  248. Private Sub BT_modvoce_Click()
  249.     If Not DB_PREV.Recordset.EOF Then
  250.         salva = True
  251.         DB_PREV.Recordset.Edit
  252.         If Qty.Text <> "" And Prscont.Text <> "" Then
  253.             DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
  254.             End If
  255.         If Qty.Text <> "" And UDC.Text <> "" Then
  256.             DB_PREV.Recordset("TOT_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
  257.          End If
  258.              If Qty.Text <> "" And MANOD.Text <> "" Then
  259.             DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
  260.          End If
  261.        
  262.        DB_PREV.Recordset.Update
  263.             salva = False
  264.         DBGrid1.SetFocus
  265.     End If
  266.     Call Calcoli
  267.     Call riordino
  268.    
  269. End Sub
  270.  
  271.  
  272. Private Sub BT_newvoce_Click()
  273.    ' flag = True
  274.     DB_PREV.Recordset.AddNew
  275.     DB_PREV.Recordset("NUMERO") = NORD.Text
  276.     DB_PREV.Recordset.Update
  277.     'con il seguente comando aggiunge voce sempre e solo alla fine del database
  278.     DB_PREV.Recordset.MoveLast
  279.     Casa.Text = ""
  280.     Codice.Text = ""
  281.     Des.Text = ""
  282.     Um.Text = ""
  283.     UDC.Text = ""
  284.     TOT_UDC.Text = ""
  285.     MANOD.Text = ""
  286.     TMANOD.Text = ""
  287.     Prunit.Text = ""
  288.     Prscont.Text = ""
  289.     Sconto.Text = ""
  290.     IVA.Text = ""
  291.     BT_var.Visible = False
  292.     BT_elart.Visible = True
  293.     BT_sta.Visible = False
  294.     BT_insnota.Visible = False
  295.    flag = True
  296.     Bt_annota.Visible = False
  297.     L_note.Visible = False
  298.     Note.Visible = False
  299.     Bt_addnota.Visible = False
  300.     BT_parz.Visible = False
  301.     BT_newvoce.Visible = False
  302.     BT_insvoce.Visible = True
  303.     BT_annvoce.Visible = True
  304.     BT_modvoce.Visible = False
  305.     BT_forn.Visible = False
  306.     BT_cancvoce.Visible = False
  307.     Call riordino
  308.     'Call Calcoli
  309.     Casa.SetFocus
  310.  
  311. End Sub
  312.  
  313. Private Sub Calcoli()
  314. Dim tipo_finmsg As String
  315. Dim Msg As String
  316. Dim IMPO, IVA, TUDC, TMANOD As Double
  317.     IMPO = 0
  318.     TUDC = 0
  319.     IVA = 0
  320.     TMANOD = 0
  321.     TOT1 = 0
  322.     UTIMP = 0
  323.   '  DB_PREV.Refresh
  324.     While Not DB_PREV.Recordset.EOF
  325.         If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
  326.             IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
  327.           End If
  328.        
  329.           If Not IsNull(DB_PREV.Recordset("TOT_UDC")) Then
  330.              TUDC = TUDC + DB_PREV.Recordset("TOT_UDC")
  331.          End If
  332.      
  333.         If Not IsNull(DB_PREV.Recordset("TMANOD")) Then
  334.              TMANOD = TMANOD + DB_PREV.Recordset("TMANOD")
  335.          End If
  336.         DB_PREV.Recordset.MoveNext
  337.         On Error GoTo errore
  338.      Wend
  339.    
  340.     IVA = IMPO * DB_STOPRE.Recordset("IVA") / 100
  341.     TOT1 = TUDC + TMANOD
  342.     UTIMP = IMPO - TOT1
  343.     tipo_finmsg = 0
  344.    
  345.     tot.Caption = Format(IMPO, F_MENU.FormatoEuro)
  346.     IVA1.Caption = Format(IVA, F_MENU.FormatoEuro)
  347.     impo1.Caption = Format(IMPO + IVA, F_MENU.FormatoEuro)
  348.     TUDC1.Caption = Format(TUDC, F_MENU.FormatoEuro)
  349.     TMANOD1.Caption = Format(TMANOD, F_MENU.FormatoEuro)
  350.     manodudc.Caption = Format(UTIMP + TMANOD, F_MENU.FormatoEuro)
  351.     utilimp.Caption = Format(IMPO - TOT1, F_MENU.FormatoEuro)
  352.    
  353.    
  354.    ' Msg = "IL TOTALE DEI CALCOLI DI PREVENTIVO é " & Chr$(13)
  355.    ' Msg = Msg & Chr$(13)
  356.    ' Msg = Msg & "IMPONIBILE : " & Chr$(32) & Format(IMPO, F_MENU.FormatoEuro) & Chr$(13)
  357.    ' Msg = Msg & "IVA        : " & Format(IVA, F_MENU.FormatoEuro) & Chr$(13)
  358.    ' Msg = Msg & "TOTALE     : " & Format(IMPO + IVA, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
  359.    
  360.    
  361.    ' Msg = Msg & "TOTALE U.D.C.   : " & Format(TUDC, F_MENU.FormatoEuro) & Chr$(13)
  362.    ' Msg = Msg & "TOT. MANOD      : " & Format(TMANOD, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
  363.    
  364.    ' Msg = Msg & "MANOD + UDC     : " & Format(TUDC + TMANOD, F_MENU.FormatoEuro) & Chr$(13)
  365.    ' Msg = Msg & "UTILE IMP.      : " & Format(IMPO - TOT1, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
  366.    
  367.    ' If MsgBox(Msg, tipo_finmsg, "CALCOLI PREVENTIVO") = 1 Then
  368.     'End If
  369. '    DB_PREV.Refresh
  370. '    DB_PREV.Recordset.MoveLast
  371.  
  372.        
  373.    '     End If
  374.      ' salva = False
  375.      
  376.      ' Call riordino
  377.    '  Me.Timer1.Enabled = True
  378. Exit Sub
  379. errore:
  380.    MsgBox "è inrtervenuto un erroe !", vbExclamation
  381.    On Error Resume Next
  382.  
  383. End Sub
  384.  
  385. Private Sub BT_sta_Click()
  386. Dim I As Byte
  387.     DB_STAMPANTI.DatabaseName = CurDir & "\SEA.mdb"
  388.     DB_STAMPANTI.RecordSource = "db_stampanti"
  389.     DB_STAMPANTI.Refresh
  390.     I = DB_STAMPANTI.Recordset("IMPOSTATA")
  391.     attualmente.Text = Printers(I).DeviceName
  392.     For I = 0 To Printers.Count - 1
  393.         Stamp.AddItem Printers(I).DeviceName, I
  394.     Next I
  395.     st.ZOrder 0
  396.     Contratto.Value = 0
  397.     st.Visible = True
  398.     Call riordino
  399.     'Call Calcoli
  400. End Sub
  401.  
  402. Private Sub BT_var_Click()
  403.     Variazione.ZOrder 0
  404.     Variazione.Visible = True
  405.     var.Text = ""
  406.     var.SetFocus
  407.     Call riordino
  408.     'Call Calcoli
  409. End Sub
  410.  
  411. Private Sub Casa_LostFocus()
  412. Dim esegui As Boolean
  413.     Casa.Text = UCase(Casa.Text)
  414.     esegui = True
  415.     If Codice.Text <> "" And flag Then
  416.         DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
  417.         DB_ARTASS.Refresh
  418.         If Not DB_ARTASS.Recordset.EOF Then
  419.             Casa = DB_ARTASS.Recordset("CASA")
  420.             Codice = DB_ARTASS.Recordset("CODICE")
  421.             Des = DB_ARTASS.Recordset("DESCRIZIONE")
  422.             Um = DB_ARTASS.Recordset("UM")
  423.             UDC = DB_ARTASS.Recordset("UDC")
  424.             MANOD = DB_ARTASS.Recordset("Manod")
  425.             Costo = DB_ARTASS.Recordset("COSTO")
  426.             Ricarico = DB_ARTASS.Recordset("RICARICO")
  427.             Prunit = DB_ARTASS.Recordset("LISTINO")
  428.             Prscont = DB_ARTASS.Recordset("LISTINO")
  429.             IVA = DB_ARTASS.Recordset("IVA")
  430.             L9.Visible = True
  431.             L10.Visible = True
  432.             Costo.Visible = True
  433.             Ricarico.Visible = True
  434.             Qty.Text = 1
  435.             Sconto.Text = 0
  436.             esegui = False
  437.         Else
  438.             Call CANCELLA
  439.         End If
  440.         If esegui Then
  441.         DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
  442.         DB_ARTICOLI.Refresh
  443.         If Not DB_ARTICOLI.Recordset.EOF Then
  444.             Casa = DB_ARTICOLI.Recordset("CASA")
  445.             Codice = DB_ARTICOLI.Recordset("CODICE")
  446.             Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
  447.             Um = DB_ARTICOLI.Recordset("UM")
  448.             Costo = DB_ARTICOLI.Recordset("COSTO")
  449.             UDC = DB_ARTICOLI.Recordset("costo")
  450.             Ricarico = DB_ARTICOLI.Recordset("RICARICO")
  451.             Prunit = DB_ARTICOLI.Recordset("LISTINO")
  452.             Prscont = DB_ARTICOLI.Recordset("LISTINO")
  453.             IVA = DB_ARTICOLI.Recordset("IVA")
  454.             L9.Visible = True
  455.             L10.Visible = True
  456.             Costo.Visible = True
  457.             Ricarico.Visible = True
  458.             Qty.Text = 1
  459.             Sconto.Text = 0
  460.             esegui = False
  461.         Else
  462.             Call CANCELLA
  463.         End If
  464.         End If
  465.     End If
  466. End Sub
  467.  
  468. Private Sub codice_LostFocus()
  469. Dim esegui As Boolean
  470.     Codice.Text = UCase(Codice.Text)
  471.     esegui = True
  472.     If Casa.Text <> "" And flag Then
  473.         DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
  474.         DB_ARTASS.Refresh
  475.         If Not DB_ARTASS.Recordset.EOF Then
  476.             Casa = DB_ARTASS.Recordset("CASA")
  477.             Codice = DB_ARTASS.Recordset("CODICE")
  478.             Des = DB_ARTASS.Recordset("DESCRIZIONE")
  479.             Um = DB_ARTASS.Recordset("UM")
  480.             UDC = DB_ARTASS.Recordset("UDC")
  481.             MANOD = DB_ARTASS.Recordset("Manod")
  482.             Costo = DB_ARTASS.Recordset("COSTO")
  483.             Ricarico = DB_ARTASS.Recordset("RICARICO")
  484.             Prunit = DB_ARTASS.Recordset("LISTINO")
  485.             Prscont = DB_ARTASS.Recordset("LISTINO")
  486.             IVA = DB_ARTASS.Recordset("IVA")
  487.             L9.Visible = True
  488.             L10.Visible = True
  489.             Costo.Visible = True
  490.             Ricarico.Visible = True
  491.             Qty.Text = 1
  492.             Sconto.Text = 0
  493.             esegui = False
  494.         Else
  495.             Call CANCELLA
  496.         End If
  497.         If esegui Then
  498.         DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
  499.         DB_ARTICOLI.Refresh
  500.         If Not DB_ARTICOLI.Recordset.EOF Then
  501.             Casa = DB_ARTICOLI.Recordset("CASA")
  502.             Codice = DB_ARTICOLI.Recordset("CODICE")
  503.             Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
  504.             Um = DB_ARTICOLI.Recordset("UM")
  505.             UDC = DB_ARTICOLI.Recordset("COSTO")
  506.             Costo = DB_ARTICOLI.Recordset("COSTO")
  507.             Ricarico = DB_ARTICOLI.Recordset("RICARICO")
  508.             Prunit = DB_ARTICOLI.Recordset("LISTINO")
  509.             Prscont = DB_ARTICOLI.Recordset("LISTINO")
  510.             IVA = DB_ARTICOLI.Recordset("IVA")
  511.      
  512.             L9.Visible = True
  513.             L10.Visible = True
  514.             Costo.Visible = True
  515.             Ricarico.Visible = True
  516.             Qty.Text = 1
  517.             Sconto.Text = 0
  518.             esegui = False
  519.         Else
  520.              Call CANCELLA
  521.         End If
  522.         End If
  523.     End If
  524. End Sub
  525.  
  526. Private Sub Command1_Click()
  527.     With F_ARTRMO
  528.         .L_DocP.Visible = True
  529.         .mnuart.Enabled = False
  530.         .mnumenu.Enabled = False
  531.         .BT_REGMOD.Visible = False
  532.         .BT_CANCELLA.Visible = False
  533.         .BT_pins.Visible = True
  534.         .BT_pann.Visible = True
  535.     End With
  536.     scelta.Visible = False
  537.     F_ARTRMO.Caption = "Inserimento Articoli Singoli in Preventivo"
  538.     F_PREINS.Hide
  539.     F_ARTRMO.Show
  540. End Sub
  541.  
  542. Private Sub Command2_Click()
  543.     With F_ASSRMO
  544.         .L_DocP.Visible = True
  545.         .mnuart.Enabled = False
  546.         .mnumenu.Enabled = False
  547.         .BT_REGMOD.Visible = False
  548.         .BT_CANCELLA.Visible = False
  549.         .BT_pins.Visible = True
  550.         .BT_pann.Visible = True
  551.     End With
  552.     scelta.Visible = False
  553.     F_ARTRMO.Caption = "Inserimento Articoli Assemblati in Preventivo"
  554.     F_PREINS.Hide
  555.     F_ASSRMO.Show
  556. End Sub
  557.  
  558. Private Sub Command3_Click()
  559.     scelta.Visible = False
  560. End Sub
  561. Private Sub Command6_Click()
  562.     Stamp.Clear
  563.     st.Visible = False
  564. End Sub
  565.  
  566. Private Sub dis_modello()
  567.     ' verticali
  568. '   Printer.Line (42, 8.5)-(95, 8.5)
  569.     Printer.Line (42, 16.5)-(95, 16.5) ', RGB(184, 227, 254), BF
  570.     Printer.Line (5, 14.5)-(42, 14.5) ', RGB(184, 227, 254), BF
  571.     Printer.Line (5, 20.5)-(95, 20.5) ', RGB(184, 227, 254), BF
  572.     Printer.Line (5, 22.5)-(95, 22.5) ', RGB(184, 227, 254), BF
  573.     Printer.Line (5, 52.5)-(84.5, 52.5) ', RGB(184, 227, 254), BF
  574.     Printer.Line (12, 54.5)-(62, 54.5) ', RGB(184, 227, 254), BF
  575.     Printer.Line (8, 56)-(62, 56) ', RGB(184, 227, 254), BF
  576.     Printer.Line (8, 57.5)-(62, 57.5) ', RGB(184, 227, 254), BF
  577.     Printer.Line (84.5, 54.5)-(95, 54.5) ', RGB(184, 227, 254), BF
  578.     Printer.Line (84.5, 56.5)-(95, 56.5) ', RGB(184, 227, 254), BF
  579.     Printer.Line (5, 58)-(95, 58) ', RGB(184, 227, 254), BF
  580.     Printer.Line (5, 60)-(18, 60) ', RGB(184, 227, 254), BF
  581.     ' orizzontali
  582.     Printer.Line (42, 14.5)-(42, 20.5) ', RGB(184, 227, 254), BF
  583.     Printer.Line (5, 14.5)-(5, 60) ', RGB(184, 227, 254), BF
  584.     Printer.Line (18, 58)-(18, 60) ', RGB(184, 227, 254), BF
  585.    ' Printer.Line (5, 12)-(5, 62)', RGB(184, 227, 254), BF
  586.     Printer.Line (20, 20.5)-(20, 22.5) ', RGB(184, 227, 254), BF
  587.     Printer.Line (58, 20.5)-(58, 52.5) ', RGB(184, 227, 254), BF
  588.    ' Printer.Line (59.5, 12)-(59.5, 62)
  589.     Printer.Line (62, 20.5)-(62, 52.5) ', RGB(184, 227, 254), BF
  590.     Printer.Line (70, 20.5)-(70, 52.5) ', RGB(184, 227, 254), BF
  591.     Printer.Line (65, 52.5)-(65, 58) ', RGB(184, 227, 254), BF
  592.     Printer.Line (84.5, 20.5)-(84.5, 58) ', RGB(184, 227, 254), BF
  593.     Printer.Line (95, 16.5)-(95, 58) ', RGB(184, 227, 254), BF
  594. End Sub
  595. Private Sub Command7_Click()
  596. Dim fine, OK As Boolean
  597. Dim impor As Double
  598. Dim d1 As String, d2 As String, D3 As String, D4 As String, D5 As String, D6 As String, D7 As String, D8 As String, D11 As String, D21 As String, D31 As String
  599. Dim i1 As String, I2 As String
  600. Dim descrizione As String
  601. Dim indi As String
  602. Dim nota As String
  603. Dim CDA As String
  604. Dim codart As String
  605. Dim Cas As String
  606. Dim Prez As Double
  607. Dim v_netto As Double
  608. Dim Qta As Long
  609. Dim Linea As Integer
  610. Dim tipo_finmsg As Integer
  611. Dim Msg, UMI As String
  612. Dim Lpt As String
  613. Dim V_IVA As Double
  614. Dim v_totale As Double
  615. Dim aliq As Single
  616. Dim lung_sta As Integer
  617. Dim colonna As Integer
  618. Dim pag As Integer
  619. Dim logo  As New StdPicture
  620. Dim Appl As Object
  621. Dim Doc As Object
  622.  
  623.      If CInt(copiuz.Text) = 0 Then GoTo Nfatt
  624.  
  625. If Stamp.ListIndex >= 0 Then
  626.     Set Printer = Printers(Stamp.ListIndex)
  627.     DB_STAMPANTI.Recordset.Edit
  628.     DB_STAMPANTI.Recordset("IMPOSTATA") = Stamp.ListIndex
  629.     DB_STAMPANTI.Recordset.Update
  630. End If
  631.  
  632. If Contratto.Value = vbChecked Then
  633.       Set Appl = CreateObject("Word.Application")
  634.     'background dell'applicazione
  635.       Appl.application.Visible = False
  636.       On Error GoTo errato
  637.       Set Doc = Appl.Documents.Open(App.Path & "\capitolato")
  638.       Doc.FormFields("Data").Result = DATA.Text 'Adesso
  639.       Appl.application.PrintOut
  640.     'chiusura dell'applicazione e Doc
  641.       Doc.CLOSE (False)
  642.       Appl.quit
  643.       Set Doc = Nothing
  644.       Set Appl = Nothing
  645. End If
  646.  
  647. ' Con 12 caratteri per pollice
  648. ' [0..95] colonne
  649. ' [0..74] righe
  650. 'On Error Resume Next
  651. Printer.ScaleMode = 4
  652. 'Printer.ScaleHeight = 330
  653. 'Printer.ScaleWidth = 217
  654. Printer.PaperSize = 9
  655. Printer.Copies = copiuz.Text
  656. 'Printer.ScaleMode = 6
  657. Printer.FontTransparent = True
  658. 'Correctly sets the background mix mode to transparent
  659. iBKMode = SetBkMode(Printer.hDC, TRANSPARENT)
  660.  
  661. If err.Number > 0 Then
  662.     tipo_finmsg = 0
  663.     Msg = "Impossibile eseguire la stampa." & Chr$(13)
  664.     Msg = Msg & "Verificare che la stampante impostata sia quella corretta"
  665.     If MsgBox(Msg, tipo_finmsg, "Stampa Preventivo") = 1 Then
  666.     End If
  667. Else
  668.     If tutte.Value = 1 Then
  669.         pag = 0
  670.     Else
  671.         pag = nump.Text
  672.     End If
  673.     attuale = 1
  674.     fine = False
  675.     DB_CLIENTI.DatabaseName = CurDir & "\SEA.mdb"
  676.     DB_CLIENTI.RecordSource = "select * from db_clienti where codice = " & DB_STOPRE.Recordset("CODCLI")
  677.     DB_CLIENTI.Refresh
  678.     aliq = DB_STOPRE.Recordset("IVA")
  679.     DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
  680.     DB_PREV.Refresh
  681. While Not fine
  682.     F_PREINS.Caption = "STAMPA DEL PREVENTIVO IN CORSO SI PREGA DI ATTENDERE"
  683.    
  684. ' parte dedicata alla stampa del modello su foglio A4
  685.  
  686. If modulo.Value = vbUnchecked Then
  687.   Set logo = LoadPicture(CurDir & "\logoP.bmp")
  688.     Printer.PaintPicture logo, 1, 1, 37, 9
  689.    
  690.    
  691.     Printer.FontName = "Arial"
  692.     Printer.ForeColor = vbBlue 'RGB(184, 227, 254)
  693.     Printer.FontSize = 7.5
  694.     Printer.CurrentX = 55
  695.     Printer.CurrentY = 2
  696.     Lpt = "IMPIANTI ELETTRICI CIVILI INDUSTRIALI"
  697.     Call Stampa(pag, Lpt)
  698.     Printer.CurrentX = 55
  699.     Printer.CurrentY = 3
  700.     Lpt = "AUDIOVISIVI - SERVICE PER CONCERTI"
  701.     Call Stampa(pag, Lpt)
  702.     Printer.CurrentX = 55
  703.     Printer.CurrentY = 4
  704.     Lpt = "COMMERCIO MATERIALE ELETTRICO - TV ANTENNE - TELEFONIA"
  705.     Call Stampa(pag, Lpt)
  706.     Printer.CurrentX = 55
  707.     Printer.CurrentY = 5
  708.     Lpt = "DOMOTICA - AUTOMATISMI - RIVELAZIONE INCENDI "
  709.     Call Stampa(pag, Lpt)
  710.     Printer.CurrentX = 55
  711.     Printer.CurrentY = 6
  712.     Lpt = "PARTITA IVA/CODICE FISCALE 0170798 034 6"
  713.     Call Stampa(pag, Lpt)
  714.     Printer.CurrentX = 55
  715.     Printer.CurrentY = 7
  716.     Lpt = "C.I.A.A. PR172901  ALBO ARTIGIANI 52134"
  717.     Call Stampa(pag, Lpt)
  718.     Printer.ForeColor = False
  719.    
  720.     dis_modello
  721.    
  722.     Printer.FontName = "Times New Roman"
  723.     Printer.FontBold = True
  724.     Printer.FontSize = 12
  725.     Printer.CurrentX = 7
  726.     Printer.CurrentY = 15
  727.     Lpt = "PREVENTIVO  N."
  728.     Call Stampa(pag, Lpt)
  729.    
  730.     Printer.CurrentX = 18
  731.     Printer.CurrentY = 17
  732.     Lpt = "DEL :"
  733.     Call Stampa(pag, Lpt)
  734.    
  735.     Printer.FontBold = False
  736.     Printer.FontSize = 7
  737.     Printer.CurrentX = 10
  738.     Printer.CurrentY = 21.1
  739.     Lpt = "CODICE"
  740.     Call Stampa(pag, Lpt)
  741.    
  742.     Printer.CurrentX = 35
  743.     Printer.CurrentY = 21.1
  744.     Lpt = "DESCRIZIONE"
  745.     Call Stampa(pag, Lpt)
  746.    
  747.     Printer.CurrentX = 59
  748.     Printer.CurrentY = 21.1
  749.     Lpt = "U.M."
  750.     Call Stampa(pag, Lpt)
  751.        
  752.     Printer.CurrentX = 64
  753.     Printer.CurrentY = 21.1
  754.     Lpt = "QUANT."
  755.     Call Stampa(pag, Lpt)
  756.    
  757.     Printer.CurrentX = 72
  758.     Printer.CurrentY = 21.1
  759.     Lpt = "PREZZO UNITARIO"
  760.     Call Stampa(pag, Lpt)
  761.    
  762.     Printer.CurrentX = 87
  763.     Printer.CurrentY = 21.1
  764.     Lpt = "IMPORTO"
  765.     Call Stampa(pag, Lpt)
  766.    
  767.     Printer.FontSize = 9
  768.     Printer.CurrentX = 76
  769.     Printer.CurrentY = 53
  770.     Lpt = "imponibile"
  771.     Call Stampa(pag, Lpt)
  772.    
  773.     Printer.CurrentX = 7
  774.     Printer.CurrentY = 53.5
  775.     Lpt = "NOTE :"
  776.     Call Stampa(pag, Lpt)
  777.    
  778.     Printer.CurrentX = 71
  779.     Printer.CurrentY = 55
  780.     Lpt = "IVA...........%"
  781.     Call Stampa(pag, Lpt)
  782.    
  783.     Printer.CurrentX = 67
  784.     Printer.CurrentY = 57
  785.     Lpt = "TOTALE  DOCUMENTO"
  786.     Call Stampa(pag, Lpt)
  787. End If
  788. ' Fine Parte dedicata alla stampa del modello su foglio A4
  789.  
  790.         If Not IsNull(DB_CLIENTI.Recordset("NOME")) Then
  791.          indi = DB_CLIENTI.Recordset("NOME")
  792.           Else
  793.             indi = ""
  794.         End If
  795.         i1 = dividi(indi, 39)
  796.         indi = Right(indi, Len(indi) - Len(i1))
  797.         I2 = dividi(indi, 39)
  798.         indi = Right(indi, Len(indi) - Len(I2))
  799.         i1 = Trim(i1)
  800.         I2 = Trim(I2)
  801.         Printer.FontBold = True
  802.         Printer.FontSize = 12
  803.         Printer.CurrentX = 52
  804.         Printer.CurrentY = 10
  805.         Call Stampa(pag, i1)
  806.         If I2 <> "" Then
  807.             Printer.CurrentX = 54
  808.             Printer.CurrentY = 11
  809.             Call Stampa(pag, I2)
  810.         End If
  811.  
  812.     Printer.FontBold = False
  813.     Printer.FontSize = 11
  814.     Printer.CurrentX = 52
  815.     Printer.CurrentY = 12
  816.     Lpt = DB_CLIENTI.Recordset("VIA")
  817.     Call Stampa(pag, Lpt)
  818.    
  819.     Printer.CurrentX = 52
  820.     Printer.CurrentY = 13
  821.     Lpt = DB_CLIENTI.Recordset("CAP") & ", " & DB_CLIENTI.Recordset("CITTA") & " " & DB_CLIENTI.Recordset("PROVINCIA")
  822.     Call Stampa(pag, Lpt)
  823.  
  824.   '  Printer.FontBold = True
  825.     Printer.CurrentX = 52
  826.     Printer.CurrentY = 17
  827.     Lpt = "P.IVA/Cod.Fisc.: " & DB_CLIENTI.Recordset("PIVA") & " "
  828.     Call Stampa(pag, Lpt)
  829.    
  830.     Printer.CurrentX = 52
  831.     Printer.CurrentY = 18
  832.     Lpt = "Telefono: " & DB_CLIENTI.Recordset("TEL") & "  - Codice Cliente : " & DB_STOPRE.Recordset("codcli")
  833.     Call Stampa(pag, Lpt)
  834.      
  835.     Printer.FontBold = True
  836.     Printer.FontSize = 13
  837.     Printer.CurrentX = 28
  838.     Printer.CurrentY = 15
  839.     Lpt = NORD.Text
  840.     Call Stampa(pag, Lpt)
  841.     Printer.CurrentX = 28
  842.     Printer.CurrentY = 17
  843.     Lpt = DATA.Text
  844.     Call Stampa(pag, Lpt)
  845.     Linea = 23
  846.    ' Printer.FontName = "Times New Roman"
  847.     Printer.FontName = "Courier New"
  848.     Printer.FontSize = 10
  849.     Printer.FontBold = False
  850.    
  851.           If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
  852.             nota = DB_STOPRE.Recordset("NOTE")
  853.         Else
  854.             nota = ""
  855.         End If
  856.         d1 = dividi(nota, 50)
  857.         nota = Right(nota, Len(nota) - Len(d1))
  858.         d2 = dividi(nota, 55)
  859.         nota = Right(nota, Len(nota) - Len(d2))
  860.         D3 = dividi(nota, 55)
  861.         d1 = Trim(d1)
  862.         d2 = Trim(d2)
  863.         D3 = Trim(D3)
  864.         Printer.CurrentX = 15
  865.         Printer.CurrentY = 53
  866.         Call Stampa(pag, d1)
  867.         If d2 <> "" Then
  868.             Printer.CurrentX = 10
  869.             Printer.CurrentY = 55
  870.             Call Stampa(pag, d2)
  871.             If D3 <> "" Then
  872.                 Printer.CurrentX = 10
  873.                 Printer.CurrentY = 56.5
  874.                 Call Stampa(pag, D3)
  875.             End If
  876.         End If
  877.    
  878.     While Not DB_PREV.Recordset.EOF And Not Linea > 51
  879.         codart = ""
  880.         Casa = ""
  881.         CDA = ""
  882.         D11 = ""
  883.         D21 = ""
  884.         D31 = ""
  885.         If Not IsNull(DB_PREV.Recordset("CASA")) Then
  886.             Cas = DB_PREV.Recordset("CASA")
  887.         End If
  888.        
  889.         If Not IsNull(DB_PREV.Recordset("CODICE")) Then
  890.             codart = DB_PREV.Recordset("CODICE")
  891.             CDA = Cas & " " & codart
  892.         End If
  893.         D11 = Mid(CDA, 1, 13)
  894.         Printer.CurrentX = 7
  895.         Printer.CurrentY = Linea
  896.         Call Stampa(pag, D11)
  897.         If Len(CDA) > 13 Then
  898.             D21 = Mid(CDA, 14, 13)
  899.             If Len(D21) > 13 Then
  900.                 D31 = Mid(CDA, 26, 13)
  901.             End If
  902.         End If
  903.         If Not IsNull(DB_PREV.Recordset("DESCRIZIONE")) Then
  904.             descrizione = DB_PREV.Recordset("DESCRIZIONE")
  905.         Else
  906.             descrizione = ""
  907.         End If
  908.         d1 = dividi(descrizione, 36)
  909.         descrizione = Right(descrizione, Len(descrizione) - Len(d1))
  910.         d2 = dividi(descrizione, 36)
  911.         descrizione = Right(descrizione, Len(descrizione) - Len(d2))
  912.         D3 = dividi(descrizione, 36)
  913.         descrizione = Right(descrizione, Len(descrizione) - Len(D3))
  914.         D4 = dividi(descrizione, 36)
  915.         descrizione = Right(descrizione, Len(descrizione) - Len(D4))
  916.         D5 = dividi(descrizione, 36)
  917.         descrizione = Right(descrizione, Len(descrizione) - Len(D5))
  918.         D6 = dividi(descrizione, 36)
  919.         descrizione = Right(descrizione, Len(descrizione) - Len(D6))
  920.         D7 = dividi(descrizione, 36)
  921.         descrizione = Right(descrizione, Len(descrizione) - Len(D7))
  922.         D8 = dividi(descrizione, 36)
  923.         d1 = Trim(d1)
  924.         d2 = Trim(d2)
  925.         D3 = Trim(D3)
  926.         D4 = Trim(D4)
  927.         D5 = Trim(D5)
  928.         D6 = Trim(D6)
  929.         D7 = Trim(D7)
  930.         D8 = Trim(D8)
  931.        
  932.         Printer.CurrentX = 20
  933.         Printer.CurrentY = Linea
  934.         Call Stampa(pag, d1)
  935.        
  936.         If Not IsNull(DB_PREV.Recordset("UM")) Then
  937.             UMIS = DB_PREV.Recordset("UM")
  938.             Printer.CurrentX = 59
  939.             Printer.CurrentY = Linea
  940.             Call Stampa(pag, Um)
  941.         End If
  942.        
  943.         If Not IsNull(DB_PREV.Recordset("QUANTITA")) Then
  944.             Qta = DB_PREV.Recordset("QUANTITA")
  945.             If Qta - Int(Qta) = 0 Then
  946.                 lung_sta = Len(Format(Qta, F_MENU.FormatoEuro))
  947.                 Printer.CurrentX = 68 - lung_sta
  948.                 Printer.CurrentY = Linea
  949.                 Call Stampa(pag, (Format(Qty, F_MENU.FormatoEuro)))
  950.             Else
  951.                 lung_sta = Len(Format(Qty, F_MENU.FormatoEuro))
  952.                 Printer.CurrentX = 68 - lung_sta
  953.                 Printer.CurrentY = Linea
  954.                 Call Stampa(pag, Format(Qty, F_MENU.FormatoEuro))
  955.             End If
  956.         End If
  957.        
  958.         If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
  959.             Prez = DB_PREV.Recordset("PREZZO")
  960.             lung_sta = Len(Format(Prez, F_MENU.FormatoEuro))
  961.             colonna = 81 - lung_sta
  962.             Printer.CurrentX = colonna
  963.             Printer.CurrentY = Linea
  964.             Call Stampa(pag, Format(Prez, F_MENU.FormatoEuro))
  965.         End If
  966.        
  967.         If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
  968.             impor = DB_PREV.Recordset("IMPORTO")
  969.             lung_sta = Len(Format(impor, F_MENU.FormatoEuro))
  970.             colonna = 94 - lung_sta
  971.             Printer.CurrentX = colonna
  972.             Printer.CurrentY = Linea
  973.             Call Stampa(pag, Format(impor, F_MENU.FormatoEuro))
  974.         End If
  975.        
  976.         If d2 <> "" Or D21 <> "" Then
  977.             Linea = Linea + 1
  978.             If d2 <> "" Then
  979.                 Printer.CurrentX = 20
  980.                 Printer.CurrentY = Linea
  981.                 Call Stampa(pag, d2)
  982.             End If
  983.             If D21 <> "" Then
  984.                 Printer.CurrentX = 7
  985.                 Printer.CurrentY = Linea
  986.                 Call Stampa(pag, D21)
  987.             End If
  988.             If D3 <> "" Or D31 <> "" Then
  989.                 Linea = Linea + 1
  990.                 If D3 <> "" Then
  991.                     Printer.CurrentX = 20
  992.                     Printer.CurrentY = Linea
  993.                     Call Stampa(pag, D3)
  994.                 End If
  995.                 If D31 <> "" Then
  996.                     Printer.CurrentX = 7
  997.                     Printer.CurrentY = Linea
  998.                     Call Stampa(pag, D31)
  999.                 End If
  1000.                 If D4 <> "" Then
  1001.                     Linea = Linea + 1
  1002.                     Printer.CurrentX = 20
  1003.                     Printer.CurrentY = Linea
  1004.                     Call Stampa(pag, D4)
  1005.                     If D5 <> "" Then
  1006.                         Linea = Linea + 1
  1007.                         Printer.CurrentX = 20
  1008.                         Printer.CurrentY = Linea
  1009.                         Call Stampa(pag, D5)
  1010.                         If D6 <> "" Then
  1011.                             Linea = Linea + 1
  1012.                             Printer.CurrentX = 20
  1013.                             Printer.CurrentY = Linea
  1014.                             Call Stampa(pag, D6)
  1015.                             If D7 <> "" Then
  1016.                                 Linea = Linea + 1
  1017.                                 Printer.CurrentX = 20
  1018.                                 Printer.CurrentY = Linea
  1019.                                 Call Stampa(pag, D7)
  1020.                                 If D8 <> "" Then
  1021.                                     Linea = Linea + 1
  1022.                                     Printer.CurrentX = 20
  1023.                                     Printer.CurrentY = Linea
  1024.                                     Call Stampa(pag, D8)
  1025.                                 End If
  1026.                             End If
  1027.                        End If
  1028.                     End If
  1029.                 End If
  1030.             End If
  1031.         End If
  1032.         Linea = Linea + 1
  1033.         DB_PREV.Recordset.MoveNext
  1034.     Wend
  1035.     If DB_PREV.Recordset.EOF Then
  1036.         fine = True
  1037.         Printer.CurrentX = 75
  1038.         Printer.CurrentY = 55
  1039.         Lpt = CStr(aliq)
  1040.         Call Stampa(pag, Lpt)
  1041.          
  1042.     ' Da cambiare quando la valuta sarà in EURO
  1043.         Netto (aliq)
  1044.       '  S_IVA (aliq)
  1045.         v_netto = t_netto
  1046.        
  1047.         lung_sta = Len(Format(v_netto, F_MENU.FormatoEuro))
  1048.         colonna = 94 - lung_sta
  1049.         Printer.CurrentX = colonna
  1050.         Printer.CurrentY = 53
  1051.         Call Stampa(pag, Format(v_netto, F_MENU.FormatoEuro))
  1052.        
  1053.         V_IVA = T_IVA
  1054.         lung_sta = Len(Format(V_IVA, F_MENU.FormatoEuro))
  1055.         colonna = 94 - lung_sta
  1056.         Printer.CurrentX = colonna
  1057.         Printer.CurrentY = 55
  1058.         Call Stampa(pag, Format(V_IVA, F_MENU.FormatoEuro))
  1059.        
  1060.         v_totale = v_netto + V_IVA
  1061.         lung_sta = Len(Format(v_totale, F_MENU.FormatoEuro))
  1062.         colonna = 94 - lung_sta
  1063.         Printer.CurrentX = colonna
  1064.         Printer.CurrentY = 57
  1065.         Call Stampa(pag, Format(v_totale, F_MENU.FormatoEuro))
  1066.              
  1067.         Printer.CurrentX = 7
  1068.         Printer.CurrentY = 59
  1069.         Lpt = "Pagina " & attuale
  1070.         Call Stampa(pag, Lpt)
  1071.        
  1072.         Printer.EndDoc
  1073.     Else
  1074.         Printer.CurrentX = 7
  1075.         Printer.CurrentY = 59
  1076.         Lpt = "Pagina " & attuale
  1077.         Call Stampa(pag, Lpt)
  1078.        
  1079.         Printer.CurrentX = 89
  1080.         Printer.CurrentY = 57
  1081.         Call Stampa(pag, "Segue")
  1082.         If pag = 0 Then
  1083.             Printer.NewPage
  1084.             attuale = attuale + 1
  1085.         Else
  1086.             attuale = attuale + 1
  1087.         End If
  1088.     End If
  1089. Wend
  1090.  
  1091. F_PREINS.Caption = "Creazione Preventivi"
  1092. End If
  1093. On Error GoTo 0
  1094. st.Visible = False
  1095. Call riordino
  1096. 'Call Calcoli
  1097. copiuz.Text = 0
  1098. Stamp.Clear
  1099. Exit Sub
  1100. Nfatt: MsgBox "Devi dirmi Quante Copie Ne Vuoi!!!!", vbExclamation
  1101. Exit Sub
  1102. errato: MsgBox "il documento citato non e presente oppure presenta un nome errato  il nome corretto è 'Capitolato' ", vbExclamation
  1103. Resume Next
  1104. Resume
  1105. End Sub
  1106.  
  1107.  
  1108. Private Sub Command8_Click()
  1109.     Variazione.Visible = False
  1110. End Sub
  1111.  
  1112. Private Sub Command9_Click()
  1113. Dim Ric As Single
  1114.     Variazione.Visible = False
  1115.     If var.Text <> "" Then
  1116.         DB_PREV.Refresh
  1117.         salva = True
  1118.         While Not DB_PREV.Recordset.EOF
  1119.             If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
  1120.                 Ric = DB_PREV.Recordset("PREZZO") * var.Text / 100
  1121.                 DB_PREV.Recordset.Edit
  1122.                 DB_PREV.Recordset("PREZZO") = Format((DB_PREV.Recordset("PREZZOI") - Ric), F_MENU.FormatoEuro)
  1123.       '        On Error Resume Next
  1124.                 DB_PREV.Recordset("IMPORTO") = Format((DB_PREV.Recordset("PREZZO") * DB_PREV.Recordset("QUANTITA")), F_MENU.FormatoEuro)
  1125.                 DB_PREV.Recordset("SCONTO") = Format(var.Text, F_MENU.FormatoEuro)
  1126.                 DB_PREV.Recordset.Update
  1127.             End If
  1128.             DB_PREV.Recordset.MoveNext
  1129.         Wend
  1130.         salva = False
  1131.         Me.Timer1.Enabled = True
  1132.        
  1133.     End If
  1134. End Sub
  1135.  
  1136. Private Sub DB_prev_Validate(Action As Integer, Save As Integer)
  1137. If salva = False Then Save = False
  1138. End Sub
  1139.  
  1140. Private Sub Netto(V_IVA As Double)
  1141.     DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
  1142.     DB_PREV.Refresh
  1143.     t_netto = "0"
  1144.     T_IVA = "0"
  1145.     While Not DB_PREV.Recordset.EOF
  1146.         If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
  1147.             t_netto = t_netto + DB_PREV.Recordset("IMPORTO")
  1148.         End If
  1149.     DB_PREV.Recordset.MoveNext
  1150.     Wend
  1151.     T_IVA = t_netto * V_IVA / 100
  1152. End Sub
  1153. 'Private Sub S_IVA(V_IVA As Currency)
  1154. '    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
  1155. '    DB_PREV.Refresh
  1156. '       T_IVA = "0"
  1157. '        T_IVA = t_netto * V_IVA / 100
  1158. 'End Sub
  1159.  
  1160. Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
  1161.     If Chr(KeyAscii) = "g" Or Chr(KeyAscii) = "G" Then DBGrid1.Height = 8500
  1162.     If Chr(KeyAscii) = "p" Or Chr(KeyAscii) = "P" Then DBGrid1.Height = 2616
  1163. End Sub
  1164.  
  1165. Private Sub Form_Activate()
  1166.     flag = True
  1167.    ' Call Calcoli
  1168.     If BT_elart.Visible = False Then
  1169.        '  Call Calcoli
  1170.         DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
  1171.         DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
  1172.         DB_PREV.Refresh
  1173.         Call Calcoli
  1174.         flag = False
  1175.    
  1176.     End If
  1177.     DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
  1178.     DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
  1179.     DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
  1180.     DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
  1181.     DB_STOPRE.Refresh
  1182.     DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
  1183.     DB_EURO.RecordSource = "db_EURO"
  1184.     DB_EURO.Refresh
  1185.  
  1186. ' If L_DocP.Visible Then
  1187. '   Call riordino
  1188.   '  Else
  1189. '    Call Calcoli
  1190.     Call riordino
  1191.   ' End If
  1192.    
  1193.    
  1194. '   salva = False
  1195.  
  1196.    
  1197.    ' DBGrid1.Columns(0).Visible = False
  1198.     'DBGrid1.Columns(1).Visible = False
  1199.     'DBGrid1.Columns(2).Width = 620
  1200.    ' DBGrid1.Columns(2).Alignment = 2
  1201.    ' DBGrid1.Columns(3).Width = 620
  1202.    ' DBGrid1.Columns(3).Alignment = 2
  1203.    ' DBGrid1.Columns(4).Width = 920
  1204.    ' DBGrid1.Columns(4).Alignment = 2
  1205.    ' DBGrid1.Columns(5).Width = 4700
  1206.    ' DBGrid1.Columns(6).Width = 500
  1207.    ' DBGrid1.Columns(6).Alignment = 2
  1208.    ' DBGrid1.Columns(7).Width = 723
  1209.    ' DBGrid1.Columns(7).Alignment = 2
  1210.    ' DBGrid1.Columns(8).Width = 680
  1211.    ' DBGrid1.Columns(9).Width = 680
  1212.    ' DBGrid1.Columns(10).Width = 680
  1213.    ' DBGrid1.Columns(11).Width = 680
  1214.    ' DBGrid1.Columns(12).Width = 680
  1215.    ' DBGrid1.Columns(13).Width = 680
  1216.    ' DBGrid1.Columns(14).Width = 550
  1217.    ' DBGrid1.Columns(15).Width = 550
  1218.    ' DBGrid1.Columns(16).Width = 680
  1219. End Sub
  1220.  
  1221. Private Sub Form_Deactivate()
  1222. Dim IMPO, IVA, parz As Double
  1223.     IMPO = 0
  1224.     DB_PREV.Refresh
  1225.     While Not DB_PREV.Recordset.EOF
  1226.         If Not IsNull(DB_PREV.Recordset("PREZZO")) And Not IsNull(DB_PREV.Recordset("QUANTITA")) And Not IsNull(DB_PREV.Recordset("IVA")) Then
  1227.             IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
  1228.         End If
  1229.         DB_PREV.Recordset.MoveNext
  1230.     Wend
  1231.     DB_STOPRE.Recordset.Edit
  1232.     DB_STOPRE.Recordset("IMPONIBILE") = Format(IMPO, F_MENU.FormatoEuro)
  1233.     DB_STOPRE.Recordset.Update
  1234.  
  1235. End Sub
  1236.  
  1237.  
  1238. Private Sub Form_Load()
  1239. Dim X As Integer
  1240. Dim Y As Integer
  1241.     X = (Screen.Width - 11400) / 2
  1242.     Y = (Screen.Height - 8004) / 2
  1243.     F_PREINS.Move X, Y
  1244. End Sub
  1245.  
  1246. Private Sub Form_Resize()
  1247. DBGrid1.Width = Me.Width - 250
  1248.  
  1249. End Sub
  1250. Private Sub Form_Unload(Cancel As Integer)
  1251.     Call Form_Deactivate
  1252.     End
  1253. End Sub
  1254.  
  1255. Private Sub IVA_LostFocus()
  1256. Dim tipo_finmsg As String
  1257. Dim Msg As String
  1258.     If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
  1259.         tipo_finmsg = 0
  1260.         Msg = "La Quantità non è in formato numerico"
  1261.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1262.         End If
  1263.         IVA.SetFocus
  1264.     End If
  1265. End Sub
  1266.  
  1267. Private Sub MANOD_LostFocus()
  1268. Dim tipo_finmsg As String
  1269. Dim Msg As String
  1270.     If MANOD.Text <> "" And Not IsNumeric(MANOD.Text) Then
  1271.         tipo_finmsg = 0
  1272.         Msg = "Il prezzo non è in formato numerico"
  1273.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1274.         End If
  1275.         MANOD.SetFocus
  1276.     End If
  1277.    End Sub
  1278.  
  1279. Private Sub mnuesci_Click()
  1280.     Bt_addnota.Visible = True
  1281.     BT_parz.Visible = True
  1282.     BT_newvoce.Visible = True
  1283.     BT_elart.Visible = False
  1284.     L9.Visible = False
  1285.     L10.Visible = False
  1286.     Costo.Visible = False
  1287.     Ricarico.Visible = False
  1288.     BT_modvoce.Visible = True
  1289.     BT_cancvoce.Visible = True
  1290.     BT_insvoce.Visible = False
  1291.     BT_annvoce.Visible = False
  1292.     BT_forn.Visible = True
  1293.     F_PREINS.Hide
  1294.     F_MENU.Show
  1295. End Sub
  1296.  
  1297. Private Sub mnuins_Click()
  1298.     F_MENU.DATA.Text = Date
  1299.     F_MENU.DB_STOPRE.DatabaseName = CurDir & "\SEA.mdb"
  1300.     F_MENU.DB_STOPRE.RecordSource = "select * from db_stopre order by numero"
  1301.     F_MENU.DB_STOPRE.Refresh
  1302.     If Not F_MENU.DB_STOPRE.Recordset.EOF Then
  1303.         F_MENU.DB_STOPRE.Recordset.MoveLast
  1304.         F_MENU.NORD.Text = DB_STOPRE.Recordset("numero") + 1
  1305.     Else
  1306.         F_MENU.NORD.Text = 1
  1307.     End If
  1308.     F_MENU.Prev.Visible = True
  1309.     F_MENU.NORD.Visible = True
  1310.     F_MENU.dat.Visible = True
  1311.     F_MENU.DATA.Visible = True
  1312.     F_MENU.num.Visible = True
  1313.     F_MENU.V_IVA.Visible = True
  1314.     F_MENU.IVA.Visible = True
  1315.     F_MENU.BtIns.Visible = True
  1316.     F_MENU.Btann.Visible = True
  1317.     Bt_addnota.Visible = True
  1318.     BT_parz.Visible = True
  1319.     BT_newvoce.Visible = True
  1320.     BT_elart.Visible = False
  1321.     L9.Visible = False
  1322.     L10.Visible = False
  1323.     Costo.Visible = False
  1324.     Ricarico.Visible = False
  1325.     BT_modvoce.Visible = True
  1326.     BT_cancvoce.Visible = True
  1327.     BT_insvoce.Visible = False
  1328.     BT_annvoce.Visible = False
  1329.     BT_forn.Visible = True
  1330.     F_PREINS.Hide
  1331.     F_MENU.Show
  1332. End Sub
  1333.  
  1334. Private Sub mnuric_Click()
  1335.     Bt_addnota.Visible = True
  1336.     BT_parz.Visible = True
  1337.     BT_newvoce.Visible = True
  1338.     BT_elart.Visible = False
  1339.     L9.Visible = False
  1340.     L10.Visible = False
  1341.     Costo.Visible = False
  1342.     Ricarico.Visible = False
  1343.     BT_modvoce.Visible = True
  1344.     BT_cancvoce.Visible = True
  1345.     BT_insvoce.Visible = False
  1346.     BT_annvoce.Visible = False
  1347.     BT_forn.Visible = True
  1348.     F_PREINS.Hide
  1349.     F_STOPRE.Show
  1350. End Sub
  1351.  
  1352. Private Sub nump_Change()
  1353.      If nump.Text <> "" Then tutte.Value = 0
  1354. End Sub
  1355.  
  1356. Private Sub nump_GotFocus()
  1357.     If nump.Text <> "" Then tutte.Value = 0
  1358. End Sub
  1359.  
  1360. Private Sub Prscont_LostFocus()
  1361. Dim tipo_finmsg As String
  1362. Dim Msg As String
  1363.     If Prscont.Text <> "" And Not IsNumeric(Prscont.Text) Then
  1364.         tipo_finmsg = 0
  1365.         Msg = "La Quantità non è in formato numerico"
  1366.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1367.         End If
  1368.         Prscont.SetFocus
  1369.     End If
  1370. End Sub
  1371.  
  1372. Private Sub Prunit_LostFocus()
  1373. Dim tipo_finmsg As String
  1374. Dim Msg As String
  1375.     If Prunit.Text <> "" And Not IsNumeric(Prunit.Text) Then
  1376.         tipo_finmsg = 0
  1377.         Msg = "Il prezzo non è in formato numerico"
  1378.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1379.         End If
  1380.         Prunit.SetFocus
  1381.     End If
  1382.     If Prunit.Text <> "" And IsNumeric(Prunit.Text) Then
  1383.         Sconto.Text = 0
  1384.         Prscont.Text = Prunit.Text
  1385.         IVA.Text = DB_STOPRE.Recordset("IVA")
  1386.     End If
  1387. End Sub
  1388.  
  1389.  
  1390. Private Sub Qty_LostFocus()
  1391. Dim tipo_finmsg As String
  1392. Dim Msg As String
  1393.     If Qty.Text <> "" And Not IsNumeric(Qty.Text) Then
  1394.         tipo_finmsg = 0
  1395.         Msg = "La Quantità non è in formato numerico"
  1396.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1397.         End If
  1398.         Qty.SetFocus
  1399.     End If
  1400. End Sub
  1401.  
  1402.  
  1403. Private Sub r_Click()
  1404. F_PREINS.Hide
  1405. F_STOPRE.Show
  1406. F_STOPRE.Codice_Cliente.Visible = True
  1407. 'Call F_STOPRE.ordCli_Click
  1408.  
  1409. 'DB_STOPRE.RecordSource = "select * from db_stopre where codcli=" & F_STOPRE.cliente.Text
  1410. '         DB_STOPRE.Refresh
  1411. '            If DB_STOPRE.Recordset.EOF Then
  1412.                ' Call messaggio
  1413. '           End If
  1414. 'Call riord
  1415.  
  1416. End Sub
  1417.  
  1418. Private Sub Sconto_LostFocus()
  1419. Dim tipo_finmsg As String
  1420. Dim Msg As String
  1421. Dim sc As Currency
  1422.     If Sconto.Text <> "" And Not IsNumeric(Sconto.Text) Then
  1423.         tipo_finmsg = 0
  1424.         Msg = "La Quantità non è in formato numerico"
  1425.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1426.         End If
  1427.         Sconto.SetFocus
  1428.     Else
  1429.     If Sconto.Text <> "" And Prunit <> "" Then
  1430.         sc = Prunit.Text * Sconto.Text / 100
  1431.         Prscont = Prunit - sc
  1432.     End If
  1433.     End If
  1434. End Sub
  1435.  
  1436. Private Sub Timer1_Timer()
  1437. Form_Activate
  1438. 'Call Calcoli
  1439. Me.Timer1.Enabled = False
  1440. End Sub
  1441.  
  1442. Private Sub tutte_Click()
  1443.     If tutte.Value = 1 Then
  1444.         nump.Text = ""
  1445.     End If
  1446. End Sub
  1447.  
  1448. Private Sub UM_LostFocus()
  1449.     Um.Text = UCase(Um.Text)
  1450. End Sub
  1451.  
  1452. Private Sub Var_LostFocus()
  1453. Dim tipo_finmsg As String
  1454. Dim Msg As String
  1455.     If var.Text <> "" And Not IsNumeric(var.Text) Then
  1456.         tipo_finmsg = 0
  1457.         Msg = "La Quantità non è in formato numerico"
  1458.         If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
  1459.         End If
  1460.         var.SetFocus
  1461.     End If
  1462. End Sub





questo e il codice dove prelevo l'articolo

Codice sorgente - presumibilmente VB.NET

  1. Option Compare Text
  2. Dim flag, flag1 As Boolean
  3. Dim pos_db, cont, pos_ric As Integer
  4. Dim salva As Boolean
  5.  
  6. Private Sub BT_CANCELLA_Click()
  7. Dim Msg As String
  8. Dim tipo_finmsg As Integer
  9.     If Not DB_ARTICOLI.Recordset.EOF Then
  10.         tipo_finmsg = 4
  11.         Msg = "Conferma la Cancellazione dei dati di" & Chr$(13)
  12.         Msg = Msg & DB_ARTICOLI.Recordset("CASA") & " " & DB_ARTICOLI.Recordset("CODICE") & " ?"
  13.         If MsgBox(Msg, tipo_finmsg, "Cancella Dati Articolo") = 6 Then
  14.             salva = True
  15.             DB_ARTICOLI.Recordset.Delete
  16.             salva = False
  17.             DB_ARTICOLI.Recordset.MoveNext
  18.             If DB_ARTICOLI.Recordset.EOF Then
  19.                 DB_ARTICOLI.Refresh
  20.                 If Not DB_ARTICOLI.Recordset.EOF Then DB_ARTICOLI.Recordset.MoveLast
  21.             End If
  22.             flag = False
  23.             flag1 = False
  24.             ric_casa.Text = ""
  25.             Ric_cod.Text = ""
  26.             ric_des.Text = ""
  27.             flag = True
  28.             flag1 = True
  29.             DB_ART.Refresh
  30.         End If
  31.     End If
  32. End Sub
  33.  
  34. Private Sub BT_pann_Click()
  35.     BT_pins.Visible = False
  36.     BT_pann.Visible = False
  37.     BT_REGMOD.Visible = True
  38.     BT_CANCELLA.Visible = True
  39.     mnuart.Enabled = True
  40.     mnumenu.Enabled = True
  41.     F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
  42.     If L_DocP.Visible Then
  43.         F_ARTRMO.Hide
  44.         F_PREINS.Show
  45.     End If
  46.     If L_DocB.Visible Then
  47.         F_ARTRMO.Hide
  48.         F_BOLINS.Show
  49.     End If
  50.     If L_DocF.Visible Then
  51.         F_ARTRMO.Hide
  52.         F_FATINS.Show
  53.     End If
  54.     If L_DocR.Visible Then
  55.         F_ARTRMO.Hide
  56.         F_RICINS.Show
  57.     End If
  58.     L_DocF.Visible = False
  59.     L_DocP.Visible = False
  60.     L_DocB.Visible = False
  61.     L_DocR.Visible = False
  62. End Sub
  63.  
  64. Private Sub BT_pins_Click()
  65. If Not DB_ARTICOLI.Recordset.EOF Then
  66.     BT_pins.Visible = False
  67.     BT_pann.Visible = False
  68.     BT_REGMOD.Visible = True
  69.     BT_CANCELLA.Visible = True
  70.     mnuart.Enabled = True
  71.     mnumenu.Enabled = True
  72.     F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
  73.     If L_cantieri.Visible Then
  74.     With F_CANTINS
  75.         .DB_CANT.DatabaseName = CurDir & "\SEA.mdb"
  76.         .DB_CANT.RecordSource = "select * from db_cant where CANT = " & .NORD.Text & " and com = " & .com.Text
  77.         .DB_CANT.Refresh
  78.         If Not .DB_CANT.Recordset.EOF Then
  79.             .DB_CANT.Recordset.MoveLast
  80.         End If
  81.         .Casa = Casa.Text
  82.         .Codice = Codice.Text
  83.         .Des = Des.Text
  84.         .Um = Um.Text
  85.         .Costo = Prezzo.Text
  86.         .Ricarico = Ricarico.Text
  87.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  88.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  89.         .IVA = IVA.Text
  90.         .C0.Visible = True
  91.         .R0.Visible = True
  92.         .Costo.Visible = True
  93.         .Ricarico.Visible = True
  94.         .Qty.Text = 1
  95.         .Sconto.Text = 0
  96.     End With
  97.     F_ARTRMO.Hide
  98.     F_CANTINS.Show
  99.     End If
  100.     If L_DocP.Visible Then
  101.     With F_PREINS
  102.         .DB_PREV.DatabaseName = CurDir & "\SEA.mdb"
  103.         .DB_PREV.RecordSource = "select * from db_Prev where numero =" & .NORD.Text '& " order by ID"
  104.         .DB_PREV.Refresh
  105.         If Not .DB_PREV.Recordset.EOF Then
  106.             .DB_PREV.Recordset.MoveLast
  107.         End If
  108.         .Casa = Casa.Text
  109.         .Codice = Codice.Text
  110.         .Des = Des.Text
  111.         .Um = Um.Text
  112.         .Costo = Prezzo.Text
  113.         .Ricarico = Ricarico.Text
  114.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  115.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  116.         .IVA = IVA.Text
  117.         .L9.Visible = True
  118.         .L10.Visible = True
  119.         .Costo.Visible = True
  120.         .Ricarico.Visible = True
  121.         .Qty.Text = 1
  122.         .Sconto.Text = 0
  123.     End With
  124.     F_ARTRMO.Hide
  125.     F_PREINS.Show
  126.     End If
  127.     If L_DocF.Visible Then
  128.     With F_FATINS
  129.         .DB_FATTURE.DatabaseName = CurDir & "\SEA.mdb"
  130.         .DB_FATTURE.RecordSource = "select * from db_fatture where numero = " & .NORD.Text '& "order By ID"
  131.         .DB_FATTURE.Refresh
  132.         If Not .DB_FATTURE.Recordset.EOF Then
  133.             .DB_FATTURE.Recordset.MoveLast
  134.         End If
  135.         .Casa = Casa.Text
  136.         .Codice = Codice.Text
  137.         .Des = Des.Text
  138.         .Um = Um.Text
  139.         .Costo = Prezzo.Text
  140.         .Ricarico = Ricarico.Text
  141.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  142.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  143.         .IVA = IVA.Text
  144.         .L9.Visible = True
  145.         .L10.Visible = True
  146.         .Costo.Visible = True
  147.         .Ricarico.Visible = True
  148.         .Qty.Text = 1
  149.         .Sconto.Text = 0
  150.     End With
  151.     F_ARTRMO.Hide
  152.     F_FATINS.Show
  153.     End If
  154.     If L_DocFele.Visible Then
  155.     With F_FATTELE
  156.         .DB_FATTELE.DatabaseName = CurDir & "\SEA.mdb"
  157.         .DB_FATTELE.RecordSource = "select * from db_fattele where numero = " & .NORD.Text '& "order By ID"
  158.         .DB_FATTELE.Refresh
  159.         If Not .DB_FATTELE.Recordset.EOF Then
  160.             .DB_FATTELE.Recordset.MoveLast
  161.         End If
  162.         .Casa = Casa.Text
  163.         .Codice = Codice.Text
  164.         .Des = Des.Text
  165.         .Um = Um.Text
  166.         .Costo = Prezzo.Text
  167.         .Ricarico = Ricarico.Text
  168.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  169.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  170.         .IVA = IVA.Text
  171.         .L9.Visible = True
  172.         .L10.Visible = True
  173.         .Costo.Visible = True
  174.         .Ricarico.Visible = True
  175.         .Qty.Text = 1
  176.         .Sconto.Text = 0
  177.     End With
  178.     F_ARTRMO.Hide
  179.     F_FATTELE.Show
  180.     End If
  181.     If L_DocB.Visible Then
  182.     With F_BOLINS
  183.         .DB_BOLLE.DatabaseName = CurDir & "\SEA.mdb"
  184.         .DB_BOLLE.RecordSource = "select * from db_BOLLE where numero = " & .NORD.Text '& "order by ID"
  185.         .DB_BOLLE.Refresh
  186.         If Not .DB_BOLLE.Recordset.EOF Then
  187.             .DB_BOLLE.Recordset.MoveLast
  188.         End If
  189.         .Casa = Casa.Text
  190.         .Codice = Codice.Text
  191.         .Des = Des.Text
  192.         .Um = Um.Text
  193.         .Costo = Prezzo.Text
  194.         .Ricarico = Ricarico.Text
  195.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  196.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  197.         .IVA = IVA.Text
  198.         .L9.Visible = True
  199.         .L10.Visible = True
  200.         .Costo.Visible = True
  201.         .Ricarico.Visible = True
  202.         .Qty.Text = 1
  203.         .Sconto.Text = 0
  204.     End With
  205.     F_ARTRMO.Hide
  206.     F_BOLINS.Show
  207.     End If
  208. If L_DocR.Visible Then
  209.     With F_RICINS
  210.         .DB_RICEVUTE.DatabaseName = CurDir & "\SEA.mdb"
  211.         .DB_RICEVUTE.RecordSource = "select * from db_ricevute where numero = " & .NORD.Text
  212.         .DB_RICEVUTE.Refresh
  213.         If Not .DB_RICEVUTE.Recordset.EOF Then
  214.             .DB_RICEVUTE.Recordset.MoveLast
  215.         End If
  216.         .Casa = Casa.Text
  217.         .Codice = Codice.Text
  218.         .Des = Des.Text
  219.         .Um = Um.Text
  220.         .Costo = Prezzo.Text
  221.         .Ricarico = Ricarico.Text
  222.         .Prunit = DB_ARTICOLI.Recordset("LISTINO")
  223.         .Prscont = DB_ARTICOLI.Recordset("LISTINO")
  224.         .IVA = IVA.Text
  225.         .L9.Visible = True
  226.         .L10.Visible = True
  227.         .Costo.Visible = True
  228.         .Ricarico.Visible = True
  229.         .Qty.Text = 1
  230.         .Sconto.Text = 0
  231.     End With
  232.     F_ARTRMO.Hide
  233.     F_RICINS.Show
  234.     End If
  235.     L_DocF.Visible = False
  236.     L_DocP.Visible = False
  237.     L_DocB.Visible = False
  238.     L_DocR.Visible = False
  239.     L_cantieri.Visible = False
  240. End If
  241. End Sub
  242.  
  243. Private Sub BT_REGMOD_Click()
  244. Dim Msg As String
  245. Dim tipo_finmsg As Integer
  246. Dim esegui As Boolean
  247. Dim pos As Integer
  248. If Not DB_ARTICOLI.Recordset.EOF Then
  249.     esegui = True
  250.     pos = DB_ARTICOLI.Recordset.AbsolutePosition
  251.     DB_ART.Refresh
  252.     While (Not DB_ART.Recordset.EOF) And esegui
  253.         If DB_ART.Recordset("CASA") = Casa.Text And DB_ART.Recordset("CODICE") = Codice.Text And DB_ART.Recordset.AbsolutePosition <> pos Then
  254.             esegui = False
  255.         Else
  256.             DB_ART.Recordset.MoveNext
  257.         End If
  258.     Wend
  259.     If esegui Then
  260.         salva = True
  261.         DB_ARTICOLI.Recordset.Edit
  262.         If Prezzo.Text <> "" And Ricarico.Text <> "" Then
  263.             If DB_ARTICOLI.Recordset("COSTO") <> Prezzo.Text Or DB_ARTICOLI.Recordset("Ricarico") <> Ricarico.Text Or DB_ARTICOLI.Recordset("iva") <> IVA.Text Then
  264.                 DB_ARTICOLI.Recordset("data") = Date
  265.             End If
  266.             DB_ARTICOLI.Recordset("LISTINO") = Format((Prezzo.Text + (Prezzo.Text * Ricarico.Text / 100)), F_MENU.FormatoEuro)
  267.             DB_ARTICOLI.Recordset("TOTIVA") = Format(((DB_ARTICOLI.Recordset("LISTINO") * DB_ARTICOLI.Recordset("IVA") / 100)), F_MENU.FormatoEuro)
  268.             DB_ARTICOLI.Recordset("Totale") = Format((DB_ARTICOLI.Recordset("LISTINO") + (DB_ARTICOLI.Recordset("TOTIVA"))), F_MENU.FormatoEuro)
  269.         End If
  270.         DB_ARTICOLI.Recordset.Update
  271.         salva = False
  272.     Else
  273.         tipo_finmsg = 0
  274.         Msg = "Il Codice della casa " & DB_ARTICOLI.Recordset("CASA") & " è già esistente."
  275.         Msg = Msg & " La modifica non può essere registrata"
  276.         If MsgBox(Msg, tipo_finmsg, "Modifica Dati Articoli") = 1 Then
  277.             Casa.SetFocus
  278.         End If
  279.     End If
  280. End If
  281. End Sub
  282.  
  283. Private Sub BT_RIC_Click()
  284. Dim pos_str, tipo_finmsg As Integer
  285. Dim var_db, Msg As String
  286. Dim trovato As Boolean
  287. If Not DB_ARTICOLI.Recordset.EOF Then
  288. If ric_des.Text <> "" Then
  289.     trovato = False
  290.     pos_db = DB_ARTICOLI.Recordset.AbsolutePosition
  291.     cont = 1
  292.     While cont < 3 And Not trovato
  293.         While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
  294.             var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
  295.             pos_str = InStr(var_db, ric_des.Text)
  296.             If pos_str > 0 Then
  297.                 trovato = True
  298.             Else
  299.                 DB_ARTICOLI.Recordset.MoveNext
  300.                 If DB_ARTICOLI.Recordset.AbsolutePosition = pos_db Then
  301.                     cont = 3
  302.                 End If
  303.             End If
  304.         Wend
  305.         If DB_ARTICOLI.Recordset.EOF Then
  306.             DB_ARTICOLI.Refresh
  307.             cont = cont + 1
  308.         End If
  309.     Wend
  310.     If Not trovato Then
  311.         tipo_finmsg = 0
  312.         Msg = "ATTENZIONE: La parola non è presente in elenco"
  313.         If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
  314.             ric_des.SetFocus
  315.         End If
  316.     Else
  317.         BT_RIC.Visible = False
  318.         succ.Visible = True
  319.         BT_stop.Visible = True
  320.         ric_des.Locked = True
  321.     End If
  322. End If
  323. End If
  324. End Sub
  325.  
  326. Private Sub BT_STOP_Click()
  327.     BT_stop.Visible = False
  328.     succ.Visible = False
  329.     BT_RIC.Visible = True
  330.     ric_des.Locked = False
  331. End Sub
  332.  
  333. Private Sub carsca_Click()
  334.     F_ARTRMO.Hide
  335.     F_ARTINV.Show
  336. End Sub
  337.  
  338. Private Sub Casa_LostFocus()
  339.     Casa.Text = UCase(Casa.Text)
  340. End Sub
  341. Private Sub codice_LostFocus()
  342.     Codice.Text = UCase(Codice.Text)
  343. End Sub
  344. Private Sub DB_ARTICOLI_Validate(Action As Integer, Save As Integer)
  345. If salva = False Then Save = False
  346. End Sub
  347.  
  348. Private Sub Form_Activate()
  349. Dim sdir As String
  350.     sdir = CurDir
  351.     DB_ARTICOLI.DatabaseName = sdir & "\sea.mdb"
  352.     DB_ARTICOLI.RecordSource = "select * from db_articoli order by casa,codice"
  353.     DB_ARTICOLI.Refresh
  354.     DB_ART.DatabaseName = sdir & "\sea.mdb"
  355.     DB_ART.RecordSource = "select * from db_articoli order by casa,codice"
  356.     DB_ART.Refresh
  357.    
  358.    
  359.     DBGrid1.Columns(0).Width = 500
  360.     DBGrid1.Columns(0).Alignment = 0
  361.     DBGrid1.Columns(1).Width = 920
  362.     DBGrid1.Columns(1).Alignment = 0
  363.     DBGrid1.Columns(2).Width = 3500
  364.     DBGrid1.Columns(2).Alignment = 0
  365.     DBGrid1.Columns(3).Width = 380
  366.     DBGrid1.Columns(3).Alignment = 2
  367.     DBGrid1.Columns(4).Width = 870
  368.     DBGrid1.Columns(4).Alignment = 0
  369.     DBGrid1.Columns(5).Width = 750
  370.     DBGrid1.Columns(5).Alignment = 0
  371.     DBGrid1.Columns(6).Width = 750
  372.     DBGrid1.Columns(6).Alignment = 0
  373.     DBGrid1.Columns(7).Width = 750
  374.     DBGrid1.Columns(7).Alignment = 0
  375.     DBGrid1.Columns(8).Width = 750
  376.     DBGrid1.Columns(8).Alignment = 0
  377.     DBGrid1.Columns(9).Width = 700
  378.     DBGrid1.Columns(9).Alignment = 0
  379.     DBGrid1.Columns(10).Width = 750
  380.     DBGrid1.Columns(10).Alignment = 2
  381.     DBGrid1.Columns(11).Width = 750
  382.     DBGrid1.Columns(11).Alignment = 0
  383.     DBGrid1.Columns(12).Width = 750
  384.     DBGrid1.Columns(12).Alignment = 0
  385.     DBGrid1.Columns(13).Width = 750
  386.     DBGrid1.Columns(13).Alignment = 0
  387.     DBGrid1.Columns(14).Width = 1000
  388.     DBGrid1.Columns(14).Alignment = 0
  389.    
  390.     DBGrid1.SetFocus
  391.     salva = False
  392.     flag = False
  393.     flag1 = True
  394.     ric_casa = ""
  395.     Ric_cod = ""
  396.     ric_des = ""
  397.     flag = True
  398.     flag1 = True
  399.     BT_stop.Visible = False
  400.     succ.Visible = False
  401.     BT_RIC.Visible = True
  402.     ric_des.Locked = False
  403. End Sub
  404.  
  405. Private Sub Form_Load()
  406. Dim X As Integer
  407. Dim Y As Integer
  408.     X = (Screen.Width - 11400) / 2
  409.     Y = (Screen.Height - 8004) / 2
  410.     F_ARTRMO.Move X, Y
  411. End Sub
  412.  
  413. Private Sub Form_Resize()
  414. DBGrid1.Width = Me.Width - 250
  415.  
  416. End Sub
  417.  
  418. Private Sub Form_Unload(Cancel As Integer)
  419.     End
  420. End Sub
  421.  
  422. Private Sub Giacenza_LostFocus()
  423. Dim tipo_finmsg As String
  424. Dim Msg As String
  425.     If Giacenza.Text <> "" And Not IsNumeric(Giacenza.Text) Then
  426.         tipo_finmsg = 0
  427.         Msg = "La giacenza non è in formato numerico"
  428.         If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
  429.         End If
  430.         Giacenza.SetFocus
  431.     End If
  432. End Sub
  433.  
  434. Private Sub IVA_LostFocus()
  435. Dim tipo_finmsg As String
  436. Dim Msg As String
  437.     If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
  438.         tipo_finmsg = 0
  439.         Msg = "L'IVA non è in formato numerico"
  440.         If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
  441.         End If
  442.         IVA.SetFocus
  443.     End If
  444. End Sub
  445.  
  446. Private Sub list_Click()
  447.     F_ARTRMO.Hide
  448.     F_ARTAGG.Show
  449. End Sub
  450.  
  451. Private Sub mnuesci_Click()
  452.     F_ARTRMO.Hide
  453.     F_MENU.Show
  454. End Sub
  455.  
  456. Private Sub mnuins_Click()
  457.     F_ARTRMO.Hide
  458.     F_ARTINS.Show
  459. End Sub
  460.  
  461. Private Sub modtut_Click()
  462.     F_ARTRMO.Hide
  463.     F_ARTMTU.Show
  464. End Sub
  465.  
  466. Private Sub Prezzo_LostFocus()
  467. Dim tipo_finmsg As String
  468. Dim Msg As String
  469.     If Prezzo.Text <> "" And Not IsNumeric(Prezzo.Text) Then
  470.         tipo_finmsg = 0
  471.         Msg = "Il prezzo non è in formato numerico"
  472.         If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
  473.         End If
  474.         Prezzo.SetFocus
  475.     End If
  476. End Sub
  477.  
  478. Private Sub ric_casa_Change()
  479. Dim trovato As Boolean
  480. Dim var_db, var_ins As String
  481. Dim lung As Integer
  482. If flag1 Then
  483.     flag = False
  484.     Ric_cod.Text = ""
  485.     flag = True
  486.     DB_ARTICOLI.Refresh
  487.     var_ins = ric_casa.Text
  488.     lung = Len(var_ins)
  489.     While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
  490.         var_db = DB_ARTICOLI.Recordset("CASA")
  491.         var_db = Left(var_db, lung)
  492.         If var_db = var_ins Then
  493.             trovato = True
  494.             ric_casa.SetFocus
  495.         Else
  496.             DB_ARTICOLI.Recordset.MoveNext
  497.         End If
  498.     Wend
  499.     If DB_ARTICOLI.Recordset.EOF Then
  500.          DB_ARTICOLI.Refresh
  501.          ric_casa.SetFocus
  502.     End If
  503.     pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
  504. End If
  505. End Sub
  506.  
  507. Private Sub ric_cod_Change()
  508. Dim trovato As Boolean
  509. Dim var_db, var_ins As String
  510. Dim lung, pos, I As Integer
  511. If flag Then
  512.     var_ins = Ric_cod.Text
  513.     If ric_casa = "" Then
  514.         DB_ARTICOLI.Refresh
  515.         pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
  516.     End If
  517.     lung = Len(var_ins)
  518.     While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
  519.         If Ric_cod = "" Then
  520.             DB_ARTICOLI.Refresh
  521.             For I = 1 To pos_ric
  522.                 DB_ARTICOLI.Recordset.MoveNext
  523.             Next I
  524.             Ric_cod.SetFocus
  525.         End If
  526.         var_db = DB_ARTICOLI.Recordset("CODICE")
  527.         var_db = Left(var_db, lung)
  528.         If var_db = var_ins Then
  529.             trovato = True
  530.             Ric_cod.SetFocus
  531.         Else
  532.             DB_ARTICOLI.Recordset.MoveNext
  533.         End If
  534.     Wend
  535.     If DB_ARTICOLI.Recordset.EOF Then
  536.          If ric_casa = "" Then
  537.             DB_ARTICOLI.Refresh
  538.             Ric_cod.SetFocus
  539.          Else
  540.             DB_ARTICOLI.Refresh
  541.             For I = 1 To pos_ric
  542.                 DB_ARTICOLI.Recordset.MoveNext
  543.             Next I
  544.             Ric_cod.SetFocus
  545.          End If
  546.     End If
  547. End If
  548. End Sub
  549.  
  550. Private Sub Ricarico_LostFocus()
  551. Dim tipo_finmsg As String
  552. Dim Msg As String
  553.     If Ricarico.Text <> "" And Not IsNumeric(Ricarico.Text) Then
  554.         tipo_finmsg = 0
  555.         Msg = "Il ricarico non è in formato numerico"
  556.         If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
  557.         End If
  558.         Ricarico.SetFocus
  559.     End If
  560. End Sub
  561.  
  562. Private Sub sta_Click()
  563.     F_ARTRMO.Hide
  564.     F_ARTSTA.Show
  565. End Sub
  566.  
  567. Private Sub succ_Click()
  568. Dim pos_str, tipo_finmsg, I As Integer
  569. Dim var_db, Msg As String
  570. Dim trovato As Boolean
  571.     trovato = False
  572.     If Not (DB_ARTICOLI.Recordset.AbsolutePosition = 1 And cont = 2) Then
  573.         DB_ARTICOLI.Recordset.MoveNext
  574.     End If
  575.     While cont < 3 And Not trovato
  576.         While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
  577.             If DB_ARTICOLI.Recordset.AbsolutePosition >= pos_db And cont = 2 Then
  578.                 cont = 3
  579.             End If
  580.             var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
  581.             pos_str = InStr(var_db, ric_des.Text)
  582.             If pos_str > 0 Then
  583.                 trovato = True
  584.             Else
  585.                 DB_ARTICOLI.Recordset.MoveNext
  586.             End If
  587.         Wend
  588.         If DB_ARTICOLI.Recordset.EOF Then
  589.             DB_ARTICOLI.Refresh
  590.             cont = cont + 1
  591.         End If
  592.     Wend
  593.     If cont >= 3 Then
  594.         tipo_finmsg = 0
  595.         Msg = "ATTENZIONE: Tutte le occorrenze della parola sono state trovate"
  596.         If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
  597.             ric_des.SetFocus
  598.             BT_stop.Visible = False
  599.             succ.Visible = False
  600.             BT_RIC.Visible = True
  601.             ric_des.Locked = False
  602.         End If
  603.     End If
  604. End Sub



spero qualcuno mi possa riuscire a dare una mano grazie a tutti comunque per la cortesia e la
celerita delle risposte



Ultima modifica effettuata da islington il 27/06/2022 alle 0:51
PM Quote
Avatar
nessuno (Normal User)
Guru^2


Messaggi: 6403
Iscritto: 03/01/2010

Segnala al moderatore
Postato alle 7:25
Lunedì, 27/06/2022
Spiegati.

Che succede con quella chiamata? Se non dai tutti i dettagli su cosa non funziona non si potrà mai rispondere.


Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
PM Quote
Avatar
islington (Normal User)
Newbie


Messaggi: 8
Iscritto: 26/06/2022

Segnala al moderatore
Postato alle 8:49
Lunedì, 27/06/2022
ciao, grazie per l'aiuto,
allora quella chiamata dovrebbe essere  automatica ,
quando entri nel dei preventivi , infatti viene chiamato
nel form activate, e quando si opera li tutto ok funziona tutto bne .

quando voglio invece inserire un anticolo o singolo oppure assemblato
che risiede su un altra tabello , con un pulsante si richiama un altro
form dove scelgo l'elenco degli articoli, una volta selto, lo invio al documento,
sichiude qusto form e database, e invio i dati all'altro form per poi
inserirlo nel documento e salvarlo.

normalmente funzione, se metto queto calcolo automatico , quando invio
l'articolo nel form preventivo arriva solo il prezzo e se lo tento di inseirre mi da errore
(logigamente mancando dei dati )

ho provato a chiamarlo in modo diverso in posizioni diverse etc ma senza risultato.. :d:d

grazie a tutti coloro che mi potranno aiutare

PM Quote
Avatar
nessuno (Normal User)
Guru^2


Messaggi: 6403
Iscritto: 03/01/2010

Segnala al moderatore
Postato alle 9:05
Lunedì, 27/06/2022
Si fa fatica a leggere e seguire, anche per un italiano approssimativo, termini che mancano, frasi poco chiare.

Comunque, devi anche dire DOVE chiami la sub Calcoli perché io non ho il programma funzionante e non posso seguirti. A parte che, ripeto, quel codice, (che viene dal vb4) è orrendo.

Che vuoi dire con "normalmente funzione, se metto queto calcolo automatico"[/B] ???


Hai provato a fare un po' di debugging esaminando le variabili e il contenuto dei campi del record corrente?

Ultima modifica effettuata da nessuno il 27/06/2022 alle 9:21


Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
PM Quote
Avatar
islington (Normal User)
Newbie


Messaggi: 8
Iscritto: 26/06/2022

Segnala al moderatore
Postato alle 9:20
Lunedì, 27/06/2022
ciao come ho premesso è una cosa discretamente vecchia, che comunque funziona abbastanza bene ,
in quelle cose che fa.

te lo ho detto viene chiamato dal form activate nel form preins.

ora come gia premesso io non sono un granchè ma e una cosa a uso interno che  fa delle cose specifiche
che altri programmi non fanno. mi basterebbe un consiglio
ti posteri tutto il programma ma e lunghissimo.

grazie per l'aiuto.



PM Quote
Avatar
nessuno (Normal User)
Guru^2


Messaggi: 6403
Iscritto: 03/01/2010

Segnala al moderatore
Postato alle 9:39
Lunedì, 27/06/2022
Se vuoi far capire agli altri devi rispondere alle domande, altrimenti è tempo perso.

Che vuoi dire "normalmente funziona, se metto questo calcolo automatico"???

E la Activate a cui ti riferisci è questa?

Codice sorgente - presumibilmente VB.NET

  1. Private Sub Form_Activate()
  2.     flag = True
  3.    ' Call Calcoli
  4.     If BT_elart.Visible = False Then
  5.        '  Call Calcoli
  6.         DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
  7.         DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
  8.         DB_PREV.Refresh
  9.         Call Calcoli
  10.         flag = False
  11.    
  12.     End If
  13.     DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
  14.     DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
  15.     DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
  16.     DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
  17.     DB_STOPRE.Refresh
  18.     DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
  19.     DB_EURO.RecordSource = "db_EURO"
  20.     DB_EURO.Refresh
  21.  
  22. ' If L_DocP.Visible Then
  23. '   Call riordino
  24.   '  Else
  25. '    Call Calcoli
  26.     Call riordino
  27.   ' End If
  28.    
  29.    
  30. '   salva = False
  31.  
  32.    
  33.    ' DBGrid1.Columns(0).Visible = False
  34.     'DBGrid1.Columns(1).Visible = False
  35.     'DBGrid1.Columns(2).Width = 620
  36.    ' DBGrid1.Columns(2).Alignment = 2
  37.    ' DBGrid1.Columns(3).Width = 620
  38.    ' DBGrid1.Columns(3).Alignment = 2
  39.    ' DBGrid1.Columns(4).Width = 920
  40.    ' DBGrid1.Columns(4).Alignment = 2
  41.    ' DBGrid1.Columns(5).Width = 4700
  42.    ' DBGrid1.Columns(6).Width = 500
  43.    ' DBGrid1.Columns(6).Alignment = 2
  44.    ' DBGrid1.Columns(7).Width = 723
  45.    ' DBGrid1.Columns(7).Alignment = 2
  46.    ' DBGrid1.Columns(8).Width = 680
  47.    ' DBGrid1.Columns(9).Width = 680
  48.    ' DBGrid1.Columns(10).Width = 680
  49.    ' DBGrid1.Columns(11).Width = 680
  50.    ' DBGrid1.Columns(12).Width = 680
  51.    ' DBGrid1.Columns(13).Width = 680
  52.    ' DBGrid1.Columns(14).Width = 550
  53.    ' DBGrid1.Columns(15).Width = 550
  54.    ' DBGrid1.Columns(16).Width = 680
  55. End Sub



Tutte quelle righe commentate le hai modificate tu? Perché Call Calcoli era chiamato in altri punti?
Perché la Call Calcoli è commentata in altri punti del programma?

Quali sub chiami in sequenza quando non funziona ? (NON INDICARE COSA FAI ma IL NOME delle Sub che chiami).

Ma come pensi che uno possa capire cosa succede dentro un codice scritto così male, senza provarlo con l'ambiente e il debug?

Ultima modifica effettuata da nessuno il 27/06/2022 alle 9:40


Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
PM Quote
Avatar
islington (Normal User)
Newbie


Messaggi: 8
Iscritto: 26/06/2022

Segnala al moderatore
Postato alle 23:38
Lunedì, 27/06/2022
ciao , allora il programma funzionava correttamente fintanto ho inserito il calcolo automatico

i codici commentati sono cose rimosse da tanto tempo,

la chiamata call la ho posizionata io in diversi punti per vedere doveera meglio.....

la sub e quella citata,

secondo me e dai un occhiata alla  sub capisci cosa chiamam e cosa chiude ... comunque

tralasciando tutta la procedura che mi ci vuole 1 ora a dirtle tutte

quando arriva nel secondo form alla Sub BT_pins_Click()
la tringa If L_DocP.Visible Then è true
mi chiude questo form e apre l'altro, ma l'articolo non viene copiato bene .


saluti e grazie

PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo