That is not what
val() does.
val is the opposite of
str$().
where
str$() converts an integer into a string,
val() converts a string into an integer, however that string must be a numerical value eg:
a$="123"
a=val(a$)
print a
This will print 123. No suprise there, but it is the integer 123 that is being printed
You, I think, are confusing
val() with
asc().
test$="a"
print asc(test$)
This will print 97 to the screen which I believe is what you are trying to do.
Nine lives to choose from and I get stuck with this one!