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 - Velocizzare il code Vb6
Forum - Visual Basic 6 - Velocizzare il code Vb6

Avatar
nikeddy (Normal User)
Newbie


Messaggi: 3
Iscritto: 05/10/2012

Segnala al moderatore
Postato alle 9:08
Venerdė, 05/10/2012
Saluti a tutti!!!

Come posso velocizzare questo code?

Codice sorgente - presumibilmente VB.NET

  1. Private Sub ricercapertemponuova()
  2.  
  3. iconta = 0
  4. totavv = 0
  5. 'totale = 0
  6. FXG_DVD.Clear
  7. 'stit = TXT_RicDVD.Text
  8.   Set gRsDVD = New ADODB.Recordset
  9.     gsSQL = "SELECT * FROM Percorsi"
  10.     gRsDVD.Open gsSQL, gCnDatabase
  11.    
  12.    
  13.  
  14.  
  15. lcontatot = 0
  16.     iconta = 0
  17.     txt_dal.Text = "" & txt_mdal.Text & "/" & txt_gdal.Text & "/" & txt_adal.Text & ""
  18.     txt_al.Text = "" & txt_mal.Text & "/" & txt_gal.Text & "/" & txt_aal.Text & ""
  19.    
  20.    FXG_DVD.ColWidth(0) = 0
  21.     FXG_DVD.ColWidth(1) = 3500
  22.     FXG_DVD.ColWidth(2) = 800
  23.     FXG_DVD.ColWidth(3) = 1000
  24.     FXG_DVD.ColWidth(4) = 720
  25.     FXG_DVD.ColWidth(5) = 650
  26.     FXG_DVD.ColWidth(6) = 650
  27.     FXG_DVD.ColWidth(7) = 500
  28.     FXG_DVD.ColWidth(8) = 500
  29. '    FXG_DVD.ColWidth(9) = 800
  30.    
  31.     FXG_DVD.Row = 0
  32.  
  33.     FXG_DVD.rows = 1
  34.  
  35.  
  36.     FXG_DVD.ColWidth(0) = 0
  37.      
  38.     FXG_DVD.Row = 0
  39.     FXG_DVD.Col = 7
  40.     FXG_DVD.Text = "%"
  41.    
  42.     FXG_DVD.Col = 1
  43.     FXG_DVD.Text = "Percorso"
  44.    
  45.     FXG_DVD.Col = 2
  46.     FXG_DVD.Text = "CODICE"
  47.    
  48.     FXG_DVD.Col = 3
  49.     FXG_DVD.Text = "Posti Auto"
  50.    
  51.     FXG_DVD.Col = 4
  52.     FXG_DVD.Text = "Costi"
  53.    
  54.     FXG_DVD.Col = 5
  55.     FXG_DVD.Text = "Tot Pro"
  56.    
  57.      FXG_DVD.Col = 6
  58.     FXG_DVD.Text = "Tot Eff"
  59.      FXG_DVD.Col = 7
  60.     FXG_DVD.Text = "%"
  61.      FXG_DVD.Col = 8
  62.     FXG_DVD.Text = "S/P"
  63.   '   FXG_DVD.Col = 9
  64.   '  FXG_DVD.Text = "S/P.A"
  65.    
  66.    
  67.        Do While gRsDVD.EOF = False
  68.         FXG_DVD.rows = FXG_DVD.rows + 1
  69.         FXG_DVD.Row = FXG_DVD.rows - 1
  70.        
  71.         FXG_DVD.Col = 0
  72.             FXG_DVD.Text = gRsDVD("ID")
  73.             igen = gRsDVD("Codice")
  74.            
  75.              icalcolaposti = 0
  76.        itot = 0
  77.         FXG_DVD.Col = 1
  78.             FXG_DVD.Text = gRsDVD("Camminamento")
  79.        
  80.        
  81.         FXG_DVD.Col = 2
  82.           FXG_DVD.Text = gRsDVD("Codice")
  83.              FXG_DVD.Col = 5
  84.              
  85.  
  86.      iconta = 0
  87.      primoconta = 0
  88.      ivia = 0
  89.  PBarXp.WaitBarStyle = True
  90.  Me.Refresh
  91.     DoEvents
  92.    
  93.                    Set gRsGenere = New ADODB.Recordset
  94.                 gsSQL = "SELECT COD_VIA,STALLI_100 FROM COD_PERCORSI WHERE COD_PERCORSO = " & _
  95.                 igen
  96.    
  97.                 gRsGenere.Open gsSQL, gCnDatabase
  98.                  Do While gRsGenere.EOF = False
  99.                
  100.                     ivia = gRsGenere("COD_VIA")
  101.                     icontaper = gRsGenere("STALLI_100")
  102. icontaposti = 0
  103.  
  104.      iconta = 0
  105.      primoconta = 0
  106.  '    totale = 0
  107.                '-------------------------------------------------------------------------------------------------
  108.        FXG_DVD.Col = 3
  109.  
  110.   Set gRscalcolaposti = New ADODB.Recordset
  111.          gsSQL = "SELECT * FROM COD_PERCORSI WHERE COD_VIA = " & ivia & " And COD_PERCORSO = " & igen & ""
  112.         gRscalcolaposti.Open gsSQL, gCnDatabase
  113.        
  114.                     Do While gRscalcolaposti.EOF = False
  115.  
  116.   icalcolaposti = gRscalcolaposti("STALLI_TARIFFATI") + icalcolaposti
  117.  
  118.      gRscalcolaposti.MoveNext
  119.     Loop
  120.  
  121.          icontaposti = icalcolaposti + icontaposti
  122.              
  123.    gRscalcolaposti.Close
  124.            
  125.            
  126.                 '-------------------------------------------------------------------------------------------------
  127.            
  128.      FXG_DVD.Col = 4
  129.  
  130. iprovaacontare = 0
  131. PBarXp.WaitBarStyle = True
  132.  Me.Refresh
  133.     DoEvents
  134.          Set gRscalcoliamo = New ADODB.Recordset
  135.           gsSQL = "SELECT NUM_VRB FROM " & scerca & " WHERE DTA_RIL between #" & txt_dal.Text & "# AND #" & txt_al.Text & "# AND TME_RIL between """ & txt_orai.Text & """ AND """ & txt_oraf.Text & """ AND LGO_RIL = " & ivia & ""
  136.  
  137.                 gRscalcoliamo.Open gsSQL, gCnDatabase
  138.  
  139.  
  140.  
  141.                  Do While gRscalcoliamo.EOF = False
  142.  
  143.  
  144.  iconta = iconta + 1
  145.  
  146.  
  147.          gRscalcoliamo.MoveNext
  148.    
  149.     Loop
  150.     ipercentuale = (Val(icontaper) / 100) * iconta
  151.  
  152. icontailtutto = ipercentuale + icontailtutto
  153.  
  154.  
  155.     gRscalcoliamo.Close
  156.    
  157.        FXG_DVD.Col = 5
  158.  
  159.             iconta = 0
  160.             percpro = 0
  161.             contaprogrammato = 0
  162.              itotaleeffettivo = 0
  163.              If iframe = 1 Then
  164.             Set gRscalcolaprogrammato = New ADODB.Recordset
  165.                 gsSQL = "SELECT * FROM Servizi WHERE data between #" & txt_dal.Text & "# and #" & txt_al.Text & "# AND Turno < 4 AND RCodPer = " & igen & ""
  166.                 gRscalcolaprogrammato.Open gsSQL, gCnDatabase
  167.             End If
  168.            
  169.             If iframe = 2 Then
  170.               Set gRscalcolaprogrammato = New ADODB.Recordset
  171.                 gsSQL = "SELECT * FROM Servizi WHERE data between #" & txt_dal.Text & "# and #" & txt_al.Text & "# AND Turno = 4 AND RCodPer = " & igen & ""
  172.                 gRscalcolaprogrammato.Open gsSQL, gCnDatabase
  173.             End If
  174.          
  175.                  If gRscalcolaprogrammato.EOF = True Then
  176.   FXG_DVD.Text = "-"
  177.                     End If
  178.                    
  179.                  Do While gRscalcolaprogrammato.EOF = False
  180.                  
  181.         icontaorario = gRscalcolaprogrammato("Turno")
  182.                 txt_datas.Text = Format(gRscalcolaprogrammato("data"), "mm/dd/yyyy")
  183.                
  184.  primoconta = 0
  185.  contaprogrammato = contaprogrammato + 1
  186.   If contaprogrammato = 0 Then
  187.   FXG_DVD.Text = "-"
  188.    End If
  189.  
  190.  percpro = contaprogrammato
  191.  
  192.        gRscalcolaprogrammato.MoveNext
  193.  
  194.     Loop
  195.      
  196.     gRscalcolaprogrammato.Close
  197.  
  198.            gRsGenere.MoveNext
  199.  
  200.     Loop
  201.        
  202.     gRsGenere.Close
  203.     FXG_DVD.Col = 3
  204.  FXG_DVD.Text = icontaposti
  205.  totprog = contaprogrammato + totprog
  206.  
  207.  Call calcolanuovoeffettivo
  208.       gRsDVD.MoveNext
  209.       totale = 0
  210.       FXG_DVD.Col = 4
  211.  
  212.    FXG_DVD.Text = icontailtutto
  213.    lcalcolatotcam = icontailtutto + lcalcolatotcam
  214. '   ICONTAILTUTTO = 0
  215.     FXG_DVD.Col = 5
  216.   FXG_DVD.Text = contaprogrammato
  217.  
  218.    FXG_DVD.Col = 7
  219.      If contaprogrammato <> 0 And totalizziamo <> 0 Then
  220.  totperc = Val(totalizziamo) / Val(contaprogrammato) * 100
  221. FXG_DVD.Text = totperc
  222.  Else
  223.   FXG_DVD.Text = "-"
  224.   End If
  225.  
  226.       FXG_DVD.Col = 8
  227.        If icontailtutto <> 0 And totalizziamo <> 0 Then
  228.       FXG_DVD.Text = Format(Val(icontailtutto) / Val(totalizziamo), "0")
  229.        Else
  230.   FXG_DVD.Text = "-"
  231.   End If
  232.  
  233.  icontailtutto = 0
  234.     Loop
  235.  
  236.  
  237.  
  238.       gRsDVD.Close
  239.        Call calcolatxt
  240.  
  241. txt_totProg.Text = totprog
  242. txt_totEffe.Text = toteffe
  243.  If toteffe <> 0 And totprog <> 0 Then
  244.   txt_rapPE.Text = Format(Val(toteffe) / Val(totprog) * 100, "0.0")
  245.  End If
  246.  
  247. 'txt_rapPE.Text = (Val(totprog) / Val(toteffe))
  248.   txt_totavvcam.Text = lcalcolatotcam
  249.   lcalcolatotcam = 0
  250.    txt_percamsumese.Text = Val(txt_totavvcam.Text) - Val(txt_totavv.Text)
  251.  
  252.  
  253. PBarXp.WaitBarStyle = True
  254. Me.Refresh
  255.    DoEvents
  256.            
  257.  End Sub


PM Quote
Avatar
nikeddy (Normal User)
Newbie


Messaggi: 3
Iscritto: 05/10/2012

Segnala al moderatore
Postato alle 13:25
Venerdė, 05/10/2012
aiutoooo e' lento!!!

PM Quote