Calcul tremie

Description

fichier excel qui permet de calculer la charge dans un tremie.
ajout et soutirage du produit.

effectue pour un membre du site.

Source / Exemple :


Private Sub CommandButton1_Click()
Dim verif, silo As String
If OptionButton1.Value = False And OptionButton2.Value = False And OptionButton3.Value = False Then
  MsgBox ("Choisissez votre Tremie..")
   Else
    If TextBox3.Text = "" Then
     MsgBox ("Entrez le nom du fournisseur")
    Else
     If TextBox1.Text = "" Or TextBox1.Text = "0" Then
      MsgBox ("Veuillez entrer un poid en Tonne")
     Else
     
      If OptionButton1.Value = True Then
      silo = "B"
      End If
      If OptionButton2.Value = True Then
      silo = "E"
      End If
      If OptionButton3.Value = True Then
      silo = "H"
      End If
      detect_fournisseur TextBox3.Text, silo
     End If
    End If
End If
End Sub

Sub detect_fournisseur(nom As String, silo As String)
Dim i, retour, total
total = Asc(silo)
total = total - 1
total = Chr(total)
retour = True
i = 2
 While Feuil1.Range(silo & i) = "" And Feuil1.Range(silo & i) <> nom
  i = i + 1
 Wend

 If Feuil1.Range(silo & i) <> nom Then
   retour = False
   i = i - 1
   If i = 1 Or Feuil1.Range(total & "8") > 220 Then
   MsgBox ("Tremie pleine")
   Exit Sub
   Else
   Feuil1.Range(silo & i) = nom
   End If
 End If

If retour Then
   Feuil1.Range(total & i) = TextBox1.Text + Feuil1.Range(tremie & i)
   Else
   Feuil1.Range(total & i) = TextBox1.Text
End If
 
End Sub

Private Sub CommandButton2_Click()
Dim silo As String
If OptionButton1.Value = False And OptionButton2.Value = False And OptionButton3.Value = False Then
   MsgBox ("Choisissez votre Tremie..")
   Else
   If TextBox2.Text = "" Or TextBox2.Text = "0" Then
      MsgBox ("Veuillez entrer un poid en Tonne")
     Else
     If OptionButton1.Value = True Then
      silo = "B"
      End If
      If OptionButton2.Value = True Then
      silo = "E"
      End If
      If OptionButton3.Value = True Then
      silo = "H"
      End If
     soutirage TextBox2.Text, silo
     End If
   End If
End Sub

Sub soutirage(poid As Integer, silo As String)
Dim i, retour, total
i = 0 + ListBox1.ListCount
total = Asc(silo)
total = total - 1
total = Chr(total)
retour = total & "2:" & silo & "6"
If Feuil1.Range(total & "7") - poid <= 0 Then
While poid > 0
If poid > Feuil1.Range(total & "7") Then
ListBox1.AddItem Feuil1.Range(total & "7") & " T de " & Feuil1.Range(silo & "7").Text
Else
ListBox1.AddItem poid & " T de " & Feuil1.Range(silo & "7").Text
End If
poid = poid - Feuil1.Range(total & "7")
With Worksheets("Feuil1")
    .Range(total & "2:" & silo & "6").Copy
    .Range(total & "3").PasteSpecial 'operation:=xlPasteValues
End With
Feuil1.Range(total & "2:" & silo & "2").Value = ""
Wend
Else
Feuil1.Range(total & "7") = Feuil1.Range(total & 7) - poid
ListBox1.AddItem TextBox2.Text & " T de " & Feuil1.Range(silo & "7").Text
End If

End Sub

Conclusion :


Correction des bugs, et separation des boutons.
ajout de commentaire.
a vouloir allez trop vite, on fait des erreurs.
;-)

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.