Robert,
It would help if you give some idea of the use of these numbers. Do you simply want a unique identifier?
Why a number; What's wrong with the name itself?
Do the numbers have to have the same length of binary bits/bytes?
You'll need to consider the longest name you can handle...
One thing the other answers passed over is that since we are on computers, those names are *already* stored in the form of binary numbers, just like EVERYTHING else on the computer - sound, images, etc.
In this case, it is the ASCII codes used to store text. It is the computer that must be aware of the fact that those particular numbers are to be displayed as the characters we know and love and manipulate them as such instead of binary numbers, sound or images (or executable code).
I suggest that by simply using the ASCII codes themselves (packed together in a string variable), you have both a binary number unique to each name *and* they will also sort, if desired. It may be less efficient that other methods.
The trouble is ... since we don't normally want to do this, it actually takes some extra work to get at the codes and assemble (or concatenate) them, and if you need to, disassemble (or parse) them back into text. I have to do this in my VBA that sends/receives stuff in/out serial/USB ports.
Every time I have to do this kind of coding (doing what the computer does for us), I must refresh my memory, but there is the essence of the technique.
I refer to the two inverse functions CHR$() and ASC(). The way I need to use this is to store numbers into ASCII strings to move through the port. I am in essence cheating on the computer to get what I want. I am sure you can use these if it suits your needs - which I can only guess at.
This amounts to taking the ASCII codes for each character and simply packing them into the desired variable. You can't use a LONG for this since it only holds 4 bytes/characters. Perhaps a custom Object type with more bytes or an array. Then there is the Variant variable, or LSET that may provide a solution for packing them.
I hope this helps trigger a solution. I'd have to think about it more to go further since My use is different than this. Besides, it's getting late on a long day ... brain full.
I'm sure one of the MVPs will have a simple way.
Regards, Steve, N.
--- In ExcelVBA@yahoogroups.com, "Robert E. Carneal" <kentuckygenealogist@...> wrote:
>
> *Is it possible to take a person's name, and convert it to a binary number?
> I can convert any number, any number system to a binary number, but can't
> seem to figure out a way to convert names similar to:
>
> DoeJohnWilliam
> EsrankKathyMaria
> MooreJamesAndrew
> ThomasRaymondDavid
>
> And so on. When I looked on The Internet, it kept wanting me to convert
> names to Soundex codes, but I need something that generates a more unique
> number than that, if possible.
> *
> *Thank you.
>
> **Robert*
> *Genealogy without documentation is mythology! Always SOURCE your work.*
>
>
> [Non-text portions of this message have been removed]
>
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar