1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| '=======================================================================
'teste de restitution en tableau
Function NBP2(max, T)
Set sc = CreateObject("ScriptControl")
code = code & "function NBP(max){var keys= new Array(); var a = 0;for(i = 2; i <= max; i++) {var j = 1;var racine = Math.floor(Math.sqrt(i));"
code = code & "do {j++;} while(j <= racine && i%j != 0);if(j > racine) {keys.push(a);keys[a]=i;a=a+1; }};return keys}"
With sc: .Language = "JScript": .AddCode code: End With
T = Timer: NBP2 = sc.Run("NBP", max): T = Timer - T
End Function
Sub test2()
Dim T
resultat = NBP2(100000, T)
' ici je ne comprends pas j'ai un string en retour dans les variables locales
Debug.Print resultat ' ici c'est un string alors que ca ne devrait pas en être
Debug.Print "temps ecoulé " & T & " secondes"
End Sub |
Partager