Bug sur vba?

panga-panga Messages postés 4 Statut Membre -  
 amigo -
Bonsoir,
voila,je passe sur 1e macro un single en argument pour efuctuer 1 calcul(simple).le probleme est ..
-si je passe 1 multiple de 0.5 (1;1.5;ect...) tout va bien
-si je passe 0.3 ca ne va plus ..1 exemple 4.7 + 0.3 =5.00098445156
ceci est calculer directement sur la feuille..pourkoi?
Configuration: Windows XP
Internet Explorer 6.0

3 réponses

  1. amigo
     
    Bonjour,

    J'ai fait un test sur VBA Excel 2003, le resultat est correct, pas de bug.

    Private Sub CommandButton1_Click()
    Dim a As Single, b As Single
    a = 4.7: b = 0.3
    MsgBox "a + b = " & addition(a, b)
    End Sub

    Function addition(x As Single, y As Single) As Single
    addition = x + y
    End Function

    A+.
    0
    1. panga-panga Messages postés 4 Statut Membre
       
      veux tu le code?j'efectu 1e foction de tri(tableau) puis 1 calcul simple
      0
  2. amigo
     
    Donnes toujours , on verra.
    0
    1. panga-panga Messages postés 4 Statut Membre
       
      2 fontions appeles par 1 clik bouton
      Sub tri()
      c = 1
      'l = 1
      Dim x, c As Integer
      Do While c <> 50
      For x = 1 To 50
      If tabl(1, x) <> 0 Then
      If tabl(1, c) = tabl(1, x) Then
      table(1, c) = tabl(1, c)
      table(2, c) = tabl(2, c)
      table(3, c) = table(3, c) + 2
      If x <> c Then
      tabl(1, x) = 0
      tabl(2, x) = 0
      End If
      End If
      If tabl2(2, c) = tabl2(2, x) Then
      table(1, c + 50) = tabl2(1, c)
      table(2, c + 50) = tabl2(2, c)
      table(3, c + 50) = table(3, c + 50) + 1
      If x <> c Then
      tabl2(1, x) = 0
      tabl2(2, x) = 0
      End If
      End If
      End If

      Next x
      c = c + 1
      Loop
      End Sub
      Sub calcul(arg As Single)
      Dim c As Integer
      For c = 1 To 100
      If table(1, c) <> 0 Then
      Folha2.Cells(l + 6, 1) = table(3, c) & "\" & table(1, c) + 3 & "x" & 4.7 + arg & "x" & Folha4.Cells(7, 3)
      l = l + 1
      table(1, c) = 0
      table(2, c) = 0
      table(3, c) = 0
      End If
      Next c
      End Sub
      0
  3. amigo
     
    Bon voila ce que ça me donne

    Je ne suis pas attardé sur le tri parce que je n'ai pas table tabl1 et tabl2 mais j'ai supposé que c'était des entiers

    J'ai regardé de plus près la ligne
    Folha2.Cells(l + 6, 1) = table(3, c) & "\" & table(1, c) + 3 & "x" & 4.7 + arg & "x" & Folha4.Cells(7, 3)

    j'ai remplacé table(3, c) par 1, table(1, c) par 1 et arg par 0.3
    j'ai mis dans la cellule C7 (cells(7,3)) la valeur 5

    Sub essai()
    Folha2.Cells(6, 1) = 1 & "\" & 1 + 3 & "x" & 4.7 + 0.3 & "x" & Folha2.Cells(7, 3)
    End Sub

    Apres execution la cellule A6 (Cells(6, 1)) contient le texte "1\4x5x5", pas de valeur numérique.
    J'ai pas compris.

    A+
    0