Thread: Ascii
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Ascii

Hi Syrus,

Answers inline....

Question 1:
I know how to read what kind of ASCII is standing in a cell ( Example:
6 is 54 and z is 90) but what if I want it the other way around,
displaying the leter with the code 86 for example.


Use the Chr$() function instead of the Asc() function. If you select Asc in
your code and hit F1, you will be taken to the help for the Asc function.
From there, you can click See Also and read the help on Chr.

Question 2:
And what if I want to read a multiple filled cell. A cell with for
example VW as Value?


For this one, you can read the entire string into a variable and step
through it with a loop:

Sub test2()
Dim s As String
Dim n As Integer

s = Sheet1.Range("A1").Text
For n = 1 To Len(s)
MsgBox Asc(Mid$(s, n, 1))
Next n
End Sub

Question 3:
Can I rip the contens of the cell apart and check if the Carathers
used in a cell are for example letters ( like ASCII between 65 and 90)


Sub test3()
Dim s As String
Dim n As Integer
Dim nCode As Integer
Dim bBadData As Boolean

s = Sheet1.Range("A1").Text
For n = 1 To Len(s)
nCode = Asc(Mid$(s, n, 1))
If nCode < 65 Or (nCode 90 And (nCode < 97 _
Or nCode 122)) Then
bBadData = True
Exit For
End If
Next n

If bBadData Then MsgBox ("Invalid character(s)")
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]