Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    Errore: routine troppo lunga

    e' cosi' lunga che non ci sta neanche in un messaggio
    quando schiaccio il tasto contenente questo codice mi da errore "rouitine troppo lunga" come posso risolvere il problema? ho pensato di dividere la routine, ma sarebbe scomodo, se magari qualcuno ha una soluzione migliore me la dia, grazie!

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Dividila in piu' sub e magari migliorala eliminando parti superflue e ripetitive ...

    Considera che da tanti anni programmo e non mi e' mai capitata una cosa del genere ...

  3. #3
    l'unico sistema che avevo era quello
    praticamente dovrei creare molte cartelle, ma solo in certe condizioni, quindi mi e' venuto un codice infinito

  4. #4
    addirittura adesso mi dice "end with senza with" mentre c'e' :
    Dim fso As FileSystemObject
    Set fso = New FileSystemObject
    With fso


    If txtGruppo10.Text = "" Then
    Label22.Caption = "Group10 not create"
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & "\" & TxtName.Text & "\" & txtGruppo10.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "1")
    '************************************************* **************************

    If txtSotto1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto1.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtSotto1.Text & "1")
    If txtUltimo1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto1.Text & "\" & txtUltimo1.Text)
    End If
    If txtUltimo2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto1.Text & "\" & txtUltimo2.Text)
    End If
    If txtUltimo3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto1.Text & "\" & txtUltimo3.Text)
    End If
    End If
    '************************************************* **************************

    If txtSotto2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto2.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtSotto2.Text & "1")
    If txtUltimo1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto2.Text & "\" & txtUltimo1.Text)
    End If
    If txtUltimo2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto2.Text & "\" & txtUltimo2.Text)
    End If
    If txtUltimo3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto2.Text & "\" & txtUltimo3.Text)
    End If
    End If
    '************************************************* **************************

    If txtSotto3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto3.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtSotto3.Text & "1")
    If txtUltimo1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto3.Text & "\" & txtUltimo1.Text)
    End If
    If txtUltimo2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto3.Text & "\" & txtUltimo2.Text)
    End If
    If txtUltimo3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto3.Text & "\" & txtUltimo3.Text)
    End If
    End If
    '************************************************* **************************

    If txtSotto4.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto4.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtSotto4.Text & "1")
    If txtUltimo1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto4.Text & "\" & txtUltimo1.Text)
    End If
    If txtUltimo2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto4.Text & "\" & txtUltimo2.Text)
    End If
    If txtUltimo3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto4.Text & "\" & txtUltimo3.Text)
    End If
    End If
    '************************************************* **************************

    If txtSotto5.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto5.Text)
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtSotto5.Text & "1")
    If txtUltimo1.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto5.Text & "\" & txtUltimo1.Text)
    End If
    If txtUltimo2.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto5.Text & "\" & txtUltimo2.Text)
    End If
    If txtUltimo3.Text = "" Then
    Label22.Caption = "..."
    Else
    .CreateFolder (App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text & "\" & txtSotto5.Text & "\" & txtUltimo3.Text)
    End If
    End If
    End With
    Set fso = Nothing

  5. #5
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Intanto, non capisco perche' ripeti sempre la parte

    App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text

    che mi sembra abbastanza comune alle chiamate ...

    All'inizio dovresti usare una variabile

    codice:
    Dim Rdx As String
    Rdx = App.Path & "\" & "Source" & "\" & "Machine" & "\" & TxtName.Text & "\" & txtGruppo10.Text
    ed utilizzarla in modo da rendere piu' compatto e leggibile il codice, ad esempio

    codice:
    .CreateFolder (Rdx)
    .CreateFolder (Rdx & "1")
    Poi dovresti cercare di scrivere una funzione che raggruppi piu' linee (logicamente unite da uno scopo) ed usarla passandole i parametri.

    Inoltre, anche se non conosco il tipo di lavoro che stai facendo, penso che se tu usassi degli array di controlli (per le textbox), potresti usufruire dei cicli per effettuare lo stesso lavoro in poche righe ...

    Per finire, il problema della with e' molto probabilmente causato dal fatto che uno dei blocchi IF..ENDIF non e' coerente. E questo fa "sballare" il controllo della "WITH..ENDWITH"

  6. #6
    ne dovrei creare un bel po' di variabili, comunque quello che sto facendo dovrebbe essere una routine in cui mi crea delle cartelle (il nome delle cartelle e' uguale al nome di alcune txtbox) , pero' se la textbox e' vuota non deve crearmi le cartelle. il problema e' che sono tre cartelle una dentro l'altra, cioe' magari ho dieci cartelle iniziali e x ognuna di queste cartelle all'interno ce ne vanno altre, e all'interno di quest'ultime ce ne vanno ancora altre, il che diventa abbastanza complicato e il codice e' infinito, ora sto provando un'altra strada, sperando che funzioni

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.