J
Jason
How do I get the numeric value of a character without using a for 65 + 1 to
24 loop for checking chr(counter) = text?
24 loop for checking chr(counter) = text?
Jason said:How do I get the numeric value of a character without using a for 65 + 1
to
24 loop for checking chr(counter) = text?
Klatuu said:Okay. As I recall, you said all the letters are upper case. If that is the
case and their will not be any numbers or other characters in the string, you
don't have to go through the exercise 26 times. You only need to do it as
many times as the length of the string.
BTW, you have Chr backwards. It returns the character represented by an
ASCII number. for example, Chr("Z") will return 90. The ASC(90) will return
Z. When you add 1 to 90, the Chr(91) returns [
So here is a function that does what you describe:
Function AddOneToIt(StartString) As String
Dim lngI as Long
For lngI = 1 To len(StartString)
AddOneToIt = AddOneToIt & Chr(Asc(Mid(StartSTring,lngI,1)) + 1)
Next lngI
End Function
So if you pass a string of "ABC" it will return "BCD"
A string of "XYZ" will return "YZ["
Is that what you are trying to do?
--
Dave Hargis, Microsoft Access MVP
Jason said:I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.
times
of The
Ascii different.
But, that
has for
65 +
Jason said:The length of the string is 1. The number of possibilies is 26.
Klatuu said:Okay. As I recall, you said all the letters are upper case. If that is the
case and their will not be any numbers or other characters in the string, you
don't have to go through the exercise 26 times. You only need to do it as
many times as the length of the string.
BTW, you have Chr backwards. It returns the character represented by an
ASCII number. for example, Chr("Z") will return 90. The ASC(90) will return
Z. When you add 1 to 90, the Chr(91) returns [
So here is a function that does what you describe:
Function AddOneToIt(StartString) As String
Dim lngI as Long
For lngI = 1 To len(StartString)
AddOneToIt = AddOneToIt & Chr(Asc(Mid(StartSTring,lngI,1)) + 1)
Next lngI
End Function
So if you pass a string of "ABC" it will return "BCD"
A string of "XYZ" will return "YZ["
Is that what you are trying to do?
--
Dave Hargis, Microsoft Access MVP
Jason said:I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.
Okay, but what is the actual objective here? What is it you want to
accomplish?
--
Dave Hargis, Microsoft Access MVP
:
Actually I could create the function from chr to 256.
i need to know the CHR NUMBER. All letters are uppercase so 26 times
of
UCase(letter) would be fine.
If what you are trying to do is determine whether a specific
character
is
in
the alphabet, you would have to go through the loop 52 times. The
Ascii
representation for lower case and upper case letters is different.
But,
a
normal character comparison in Access sees them as the same. For
example,
"A" = "a" is true. So here is another way. Create a string that
has
all
the
letters of the alphbet:
strAlphabet = "abcdefghijklmnopqrstuvwxyz"
Then use the Instr function to determine if it is a letter. If the
Instr
returns 0, it is not.
If Instr(strAlhpabet, text) = 0 Then
'Not a Letter
End If
--
Dave Hargis, Microsoft Access MVP
:
How do I get the numeric value of a character without using a for
65 +
1
to
24 loop for checking chr(counter) = text?
If Z make A then work with the previous character.Klatuu said:Sorry, Jason, your descriptions are a bit cryptic.
You said:
I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.
get the next letter. It is easy to add (get next number) 1 to 1 to make 2"each letter" sounds like more than 1
"add 1 if it is less than Z" The function I posted does that.
So why would you need to interate through it 26 times. How else would you
Everything is done to seperate the 1 character from the string then put theSay, your one letter is "A".
What do you want it to be when you are done? the next letter would be B.
Believe me, I am trying to help, but you aren't giving me much to work with.
A bit more detail and we can get there.
--
Dave Hargis, Microsoft Access MVP
Jason said:The length of the string is 1. The number of possibilies is 26.
isKlatuu said:Okay. As I recall, you said all the letters are upper case. If that
thestring,case and their will not be any numbers or other characters in the
youtimes.don't have to go through the exercise 26 times. You only need to do it as
many times as the length of the string.
BTW, you have Chr backwards. It returns the character represented by an
ASCII number. for example, Chr("Z") will return 90. The ASC(90) will return
Z. When you add 1 to 90, the Chr(91) returns [
So here is a function that does what you describe:
Function AddOneToIt(StartString) As String
Dim lngI as Long
For lngI = 1 To len(StartString)
AddOneToIt = AddOneToIt & Chr(Asc(Mid(StartSTring,lngI,1)) + 1)
Next lngI
End Function
So if you pass a string of "ABC" it will return "BCD"
A string of "XYZ" will return "YZ["
Is that what you are trying to do?
--
Dave Hargis, Microsoft Access MVP
:
I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.
Okay, but what is the actual objective here? What is it you want to
accomplish?
--
Dave Hargis, Microsoft Access MVP
:
Actually I could create the function from chr to 256.
i need to know the CHR NUMBER. All letters are uppercase so 26 times
of
UCase(letter) would be fine.
If what you are trying to do is determine whether a specific
character
is
in
the alphabet, you would have to go through the loop 52
TheIfAscii
representation for lower case and upper case letters is different.
But,
a
normal character comparison in Access sees them as the same. For
example,
"A" = "a" is true. So here is another way. Create a string that
has
all
the
letters of the alphbet:
strAlphabet = "abcdefghijklmnopqrstuvwxyz"
Then use the Instr function to determine if it is a letter.
theusing aInstr
returns 0, it is not.
If Instr(strAlhpabet, text) = 0 Then
'Not a Letter
End If
--
Dave Hargis, Microsoft Access MVP
:
How do I get the numeric value of a character without
for65 +
1
to
24 loop for checking chr(counter) = text?
UpRider said:I don't know what a database plate is, but I know the the chr value of a
letter is returned by the function asc().
UpRider
Jason said:If Z make A then work with the previous character.Klatuu said:Sorry, Jason, your descriptions are a bit cryptic.
You said:
I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.get the next letter. It is easy to add (get next number) 1 to 1 to make 2"each letter" sounds like more than 1
"add 1 if it is less than Z" The function I posted does that.
So why would you need to interate through it 26 times. How else would you
but adding (getting next character) 1 character to A is a bit more difficult
(A + what = B?). The only way is to get the chr number and add 1 to that
then convert back to text by using CHR. I've already got the while loop as
this appears to be the only wayEverything is done to seperate the 1 character from the string then put theSay, your one letter is "A".
What do you want it to be when you are done? the next letter would be B.
next one back.Believe me, I am trying to help, but you aren't giving me much to work with.
A bit more detail and we can get there.
--
Dave Hargis, Microsoft Access MVP
Jason said:The length of the string is 1. The number of possibilies is 26.
Okay. As I recall, you said all the letters are upper case. If that is
the
case and their will not be any numbers or other characters in the string,
you
don't have to go through the exercise 26 times. You only need to do it as
many times as the length of the string.
BTW, you have Chr backwards. It returns the character represented by an
ASCII number. for example, Chr("Z") will return 90. The ASC(90) will
return
Z. When you add 1 to 90, the Chr(91) returns [
So here is a function that does what you describe:
Function AddOneToIt(StartString) As String
Dim lngI as Long
For lngI = 1 To len(StartString)
AddOneToIt = AddOneToIt & Chr(Asc(Mid(StartSTring,lngI,1)) + 1)
Next lngI
End Function
So if you pass a string of "ABC" it will return "BCD"
A string of "XYZ" will return "YZ["
Is that what you are trying to do?
--
Dave Hargis, Microsoft Access MVP
:
I have plates that contain letters. The first thing I need to do is
determine the chr number of each letter then add 1 if it is less than Z.
Okay, but what is the actual objective here? What is it you want to
accomplish?
--
Dave Hargis, Microsoft Access MVP
:
Actually I could create the function from chr to 256.
i need to know the CHR NUMBER. All letters are uppercase so 26
times
of
UCase(letter) would be fine.
If what you are trying to do is determine whether a specific
character
is
in
the alphabet, you would have to go through the loop 52 times.
The
Ascii
representation for lower case and upper case letters is
different.
But,
a
normal character comparison in Access sees them as the same.
For
example,
"A" = "a" is true. So here is another way. Create a string
that
has
all
the
letters of the alphbet:
strAlphabet = "abcdefghijklmnopqrstuvwxyz"
Then use the Instr function to determine if it is a letter. If
the
Instr
returns 0, it is not.
If Instr(strAlhpabet, text) = 0 Then
'Not a Letter
End If
--
Dave Hargis, Microsoft Access MVP
:
How do I get the numeric value of a character without using a
for
65 +
1
to
24 loop for checking chr(counter) = text?