Member Avatar for breezyy

Hey there,
I am trying to make a unique ID for each of my records. So in my "First Name" and "Last Name" fields, I am trying to ADD ALL of the characters' ASCII code in both fields. AN e.g

First Name : JOHN (string)
Last Name : DOE(string)

Member ID should be : (Ascii of J) + (Ascii of O) + (Ascii of H) and so on till (Ascii of E) (in Last Name).

The problem with this is that the asc(string) command, returns the value of only the 1st letter in the string.
Any ideas?

Thanks

Recommended Answers

All 2 Replies

Dear Breezyy

The Asc() function returns the ascii value of only one character at a time. If u want to get the ascii values of a group of characters, u have to use the Asc() for each character one at a time. U can use For...Next to loop thru the characters of the string.

Dim xStr as String
Dim iVar as Integer
Dim tStr as Long

tStr =0
xStr = "Mark"

For iVar = 1 to Len(xStr)

    tStr = tStr + Asc(Mid(xStr,iVar,1)

Next iVar

But i dont get the point in saving ascii codes in the DB. if u join all the asc code of a string, how would u create an Unique ID. For eg if ABCD will result in 65+66+67+68=266 then XZX also results in 88+90+88=266. The how can there be uniqueness? I am actually not sure whether i have understood ur concept or not, but that is the doubt i had. Any How all the best dear. hope it solves ur problem

Regards
Shaik Akthar

I am trying to make a unique ID for each of my records.

Yes I agree Addition of Ascii dont give a unique number as Shaik Akthar. Better to use Auto Number or Other Algorithm.

Addition of Ascii of ABCD is same as Addition of Ascii of ABDC, BACD, and all its combination.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.