Accueil > > > GENERATEUR DE TABLEAUX DE NOMBRES POUR VB/VBA
GENERATEUR DE TABLEAUX DE NOMBRES POUR VB/VBA
Information sur la source
Description
Démo faite sur Excel. Fichier xls, dll (C et ASM), et txt contenant code de la dll dans zip. La dll ne génère que des tableaux de Long dans cette démo, chacun étendra selon ses besoins, si problème demander. Si gros tableau généré en début de procédure et plus utile par la suite, ne pas oublier de lui faire un 'erase'. Appel SetCurrentDirectory dans Workbook_Open() permet de mettre la dll dans même dossier que le xls.
Source
- ' ------------------------ WORKBOOK OPEN
- Declare Sub SetCurrentDirectoryA Lib "Kernel32.dll" (ByVal pdir As String)
- ' ------------------------
-
- Declare Function bnTablEstNull Lib "bnArray.dll" (ptbl() As Any) As Long
-
- Declare Function bnTablInt32Alea Lib "bnArray.dll" (ByVal nelems As Long) As Long()
- Declare Function bnTablInt32AleaPstf Lib "bnArray.dll" (ByVal nelems As Long) As Long()
- ' PLAGE 24 BITS, 0 => 16777215
- Declare Function bnTablInt32TriAZ Lib "bnArray.dll" (ptbl() As Long) As Long
- ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
- Declare Function bnTablInt32TriZA Lib "bnArray.dll" (ptbl() As Long) As Long
- ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
- Declare Function bnTablInt32INVRS Lib "bnArray.dll" (ptbl() As Long) As Long
- ' RETOURNE LE NBR ELEMS INVERSES OU ZERO SI PAS BON
- Declare Function bnTablInt32AleaUnic Lib "bnArray.dll" (ByVal mini As Long, ByVal maxi As Long) As Long()
- ' PLAGE 16 BITS, mini >= 0, maxi <= 65535, maxi >= mini
- ' Sortira tableau valeurs uniques de nelems = (maxi - mini + 1)
- Declare Function bnTablInt32AleaBorne Lib "bnArray.dll" (ByVal nelems As Long, ByVal mini As Long, ByVal maxi As Long) As Long()
- ' PLAGE 16 BITS, mini >= 0, maxi <= 65535, maxi >= mini
- ' AUCUN TEST D'UNICITE DES VALEURS QUI SORTENT
-
- ' ------------------------
- Private Sub Workbook_Open()
- SetCurrentDirectoryA ThisWorkbook.Path
- End Sub
- ' ------------------------
-
- Sub TestInt32()
- Dim tabl() As Long, i As Long, maxi As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32Alea(1000)
- If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE
- Cells(1, 1) = "DEFAUT MEMOIRE"
- Exit Sub
- End If
- maxi = UBound(tabl)
- For i = 0 To maxi
- Cells(i + 1, 1) = tabl(i)
- Next i
- End Sub
-
- Sub TestIn32Positifs()
- Dim tabl() As Long, i As Long, maxi As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32AleaPstf(500)
- If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE
- Cells(1, 1) = "DEFAUT MEMOIRE"
- Exit Sub
- End If
- maxi = UBound(tabl)
- For i = 0 To maxi
- Cells(i + 1, 1) = tabl(i)
- Next i
- End Sub
-
- Sub TrierTablLong()
- Dim tabl() As Long, tries As Long, i As Long, ubnd As Long, r As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32AleaPstf(2000)
- ' tries = bnTablInt32TriAZ(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
- tries = bnTablInt32TriZA(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
- Cells(1, 2) = tries
- If tries = 0 Then Exit Sub
- i = LBound(tabl)
- ubnd = UBound(tabl)
- If tries <> (ubnd - i + 1) Then Exit Sub
- r = 0
- While i <= ubnd
- r = r + 1
- Cells(r, 1) = tabl(i)
- i = i + 1
- Wend
- End Sub
-
- Sub ReverseTablLong()
- Dim tabl() As Long, tries As Long, i As Long, ubnd As Long, r As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32AleaPstf(25)
- tries = bnTablInt32TriAZ(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
- Cells(1, 2) = tries
- If tries = 0 Then Exit Sub
- i = LBound(tabl)
- ubnd = UBound(tabl)
- If tries <> (ubnd - i + 1) Then Exit Sub
- r = 0
- While i <= ubnd
- r = r + 1
- Cells(r, 1) = tabl(i)
- i = i + 1
- Wend
- tries = bnTablInt32INVRS(tabl) ' RETOURNE LE NBR ELEMS INVERSES OU ZERO SI PAS BON
- Cells(1, 4) = tries
- If tries = 0 Then Exit Sub
- i = LBound(tabl)
- ubnd = UBound(tabl)
- If tries <> (ubnd - i + 1) Then Exit Sub
- r = 0
- While i <= ubnd
- r = r + 1
- Cells(r, 3) = tabl(i)
- i = i + 1
- Wend
- End Sub
-
- Sub TestAleaUnic()
- Dim tabl() As Long, i As Long, ubnd As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32AleaUnic(0, 1000) ' TABLEAU DE (max - min + 1) NBR
- If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE OU ERREUR PARAMS
- Cells(1, 2) = "ERREUR"
- Exit Sub
- End If
- ubnd = UBound(tabl)
- Cells(1, 2) = ubnd + 1
- For i = 0 To ubnd
- Cells(i + 1, 1) = tabl(i)
- Next i
- End Sub
-
- Sub TestAleaBorne()
- Dim tabl() As Long, i As Long, ubnd As Long
- Columns("A:D").ClearContents
- tabl = bnTablInt32AleaBorne(1000, 0, 1000) ' TABLEAU DE x NBR COMPRIS ENTRE min ET max INCLUS
- If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE OU ERREUR PARAMS
- Cells(1, 2) = "ERREUR"
- Exit Sub
- End If
- ubnd = UBound(tabl)
- Cells(1, 2) = ubnd + 1
- For i = 0 To ubnd
- Cells(i + 1, 1) = tabl(i)
- Next i
- End Sub
' ------------------------ WORKBOOK OPEN
Declare Sub SetCurrentDirectoryA Lib "Kernel32.dll" (ByVal pdir As String)
' ------------------------
Declare Function bnTablEstNull Lib "bnArray.dll" (ptbl() As Any) As Long
Declare Function bnTablInt32Alea Lib "bnArray.dll" (ByVal nelems As Long) As Long()
Declare Function bnTablInt32AleaPstf Lib "bnArray.dll" (ByVal nelems As Long) As Long()
' PLAGE 24 BITS, 0 => 16777215
Declare Function bnTablInt32TriAZ Lib "bnArray.dll" (ptbl() As Long) As Long
' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
Declare Function bnTablInt32TriZA Lib "bnArray.dll" (ptbl() As Long) As Long
' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
Declare Function bnTablInt32INVRS Lib "bnArray.dll" (ptbl() As Long) As Long
' RETOURNE LE NBR ELEMS INVERSES OU ZERO SI PAS BON
Declare Function bnTablInt32AleaUnic Lib "bnArray.dll" (ByVal mini As Long, ByVal maxi As Long) As Long()
' PLAGE 16 BITS, mini >= 0, maxi <= 65535, maxi >= mini
' Sortira tableau valeurs uniques de nelems = (maxi - mini + 1)
Declare Function bnTablInt32AleaBorne Lib "bnArray.dll" (ByVal nelems As Long, ByVal mini As Long, ByVal maxi As Long) As Long()
' PLAGE 16 BITS, mini >= 0, maxi <= 65535, maxi >= mini
' AUCUN TEST D'UNICITE DES VALEURS QUI SORTENT
' ------------------------
Private Sub Workbook_Open()
SetCurrentDirectoryA ThisWorkbook.Path
End Sub
' ------------------------
Sub TestInt32()
Dim tabl() As Long, i As Long, maxi As Long
Columns("A:D").ClearContents
tabl = bnTablInt32Alea(1000)
If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE
Cells(1, 1) = "DEFAUT MEMOIRE"
Exit Sub
End If
maxi = UBound(tabl)
For i = 0 To maxi
Cells(i + 1, 1) = tabl(i)
Next i
End Sub
Sub TestIn32Positifs()
Dim tabl() As Long, i As Long, maxi As Long
Columns("A:D").ClearContents
tabl = bnTablInt32AleaPstf(500)
If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE
Cells(1, 1) = "DEFAUT MEMOIRE"
Exit Sub
End If
maxi = UBound(tabl)
For i = 0 To maxi
Cells(i + 1, 1) = tabl(i)
Next i
End Sub
Sub TrierTablLong()
Dim tabl() As Long, tries As Long, i As Long, ubnd As Long, r As Long
Columns("A:D").ClearContents
tabl = bnTablInt32AleaPstf(2000)
' tries = bnTablInt32TriAZ(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
tries = bnTablInt32TriZA(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
Cells(1, 2) = tries
If tries = 0 Then Exit Sub
i = LBound(tabl)
ubnd = UBound(tabl)
If tries <> (ubnd - i + 1) Then Exit Sub
r = 0
While i <= ubnd
r = r + 1
Cells(r, 1) = tabl(i)
i = i + 1
Wend
End Sub
Sub ReverseTablLong()
Dim tabl() As Long, tries As Long, i As Long, ubnd As Long, r As Long
Columns("A:D").ClearContents
tabl = bnTablInt32AleaPstf(25)
tries = bnTablInt32TriAZ(tabl) ' RETOURNE LE NBR ELEMS TRIES OU ZERO SI PAS BON
Cells(1, 2) = tries
If tries = 0 Then Exit Sub
i = LBound(tabl)
ubnd = UBound(tabl)
If tries <> (ubnd - i + 1) Then Exit Sub
r = 0
While i <= ubnd
r = r + 1
Cells(r, 1) = tabl(i)
i = i + 1
Wend
tries = bnTablInt32INVRS(tabl) ' RETOURNE LE NBR ELEMS INVERSES OU ZERO SI PAS BON
Cells(1, 4) = tries
If tries = 0 Then Exit Sub
i = LBound(tabl)
ubnd = UBound(tabl)
If tries <> (ubnd - i + 1) Then Exit Sub
r = 0
While i <= ubnd
r = r + 1
Cells(r, 3) = tabl(i)
i = i + 1
Wend
End Sub
Sub TestAleaUnic()
Dim tabl() As Long, i As Long, ubnd As Long
Columns("A:D").ClearContents
tabl = bnTablInt32AleaUnic(0, 1000) ' TABLEAU DE (max - min + 1) NBR
If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE OU ERREUR PARAMS
Cells(1, 2) = "ERREUR"
Exit Sub
End If
ubnd = UBound(tabl)
Cells(1, 2) = ubnd + 1
For i = 0 To ubnd
Cells(i + 1, 1) = tabl(i)
Next i
End Sub
Sub TestAleaBorne()
Dim tabl() As Long, i As Long, ubnd As Long
Columns("A:D").ClearContents
tabl = bnTablInt32AleaBorne(1000, 0, 1000) ' TABLEAU DE x NBR COMPRIS ENTRE min ET max INCLUS
If bnTablEstNull(tabl) Then ' DLL RETOURNE 0 SI MANQUE DE MEMOIRE OU ERREUR PARAMS
Cells(1, 2) = "ERREUR"
Exit Sub
End If
ubnd = UBound(tabl)
Cells(1, 2) = ubnd + 1
For i = 0 To ubnd
Cells(i + 1, 1) = tabl(i)
Next i
End Sub
Historique
- 26 octobre 2005 16:40:04 :
- Site
- 08 octobre 2006 14:07:53 :
- site
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Programme de TRI [ par jia2812 ]
Slt les progs'!Voilà, je voudrais faire 1 code qui permet de faire des tris des nombres. J'en ai fait, mais j'me demande s'il est bien optimisé?... Al
Specialiste du tri de tableaux [ par tmcuh ]
voilà j'ai un fichier à trié sur 2 colonnes à la fois la premières étant par nombre croissant jusque là cà va (je fais cà par Shell-Metzner : nickel c
tri lisbox [ par soleildz ]
salutj'ai deux colonnes ,la premireres contient des nombres etla deuxieme des mots.je veux trier suivant la premiere colonne(les nombres)dans l'ordre
tri [ par LUCA62 ]
j'ai une suite (6 nombres) de nombre à trier, voilà comment j'ai fait : public i, jdim k as integer &
Requette de tri des nombres de version [ par bizerte ]
Est-ce que vous avez une idée sur la requête qui permet de faire le tri des nombres de version (1 , 1.1 , 1.2, 1.3 ..1.10, 1.11 ,2, 2.1..) car avec Or
tri et cumul [ par detbour ]
Bonjour g recuperer les tirage de l'euromillion pour m'amuser je voudrais faire un tri. Jusque la rien de compliquer par contre en suite c pour compte
Tri de caractéres mélangés avec des chiffres [ par sacotte ]
Je cherche à trouver quelle option il faut mettre dans une requete SQL qui est en relation avec une base mdb(access) pour que le tri des nombres se fa
Cherche une fontion aléatoire :) [ par calj ]
Voila apriori cette question est pas tres compliquer.Mais voila g un probleme avec la fonction rndMetton un code dans le style :Private Sub Command1_C
prog en fortran [ par stephnico ]
Bonjour à tous,cela fait près d'une semaine que je travail sur un prog fortran qui permet de renvoyer tous les nombres premiers compris entre 1 et un
erreur d'exécution 13 [ par Mister_one7479 ]
Bonjour , je vais droit au but j'ai un problème j'ai fait une application en vb et quand je la lance tt nikel je rentre mes caractéristique entre autr
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : DATAREPORTRE : DATAREPORT par NHenry
Cliquez pour lire la suite par NHenry DATAREPORTDATAREPORT par sabrinelle
Cliquez pour lire la suite par sabrinelle
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|