# val function in asp

How do I use "VAL" function is asp?
this code here works in vb but not on asp

Mid(Temp, I, 1) = Chr(Val("&H" & Mid(HexStr, I * 2 - 1, 2)))

Thank you.
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
You don't need to use it:

Mid(Temp, I, 1) = Chr("&H" & Mid(HexStr, I * 2 - 1, 2))

This works fine w/out the Val function.
Author Commented:
thanks for your answer so maybe you could help me with this error im
getting after removing the val

error in this line

Mid(Temp, I, 1) = Chr("&H" & Mid(HexStr, I * 2 - 1, 2))

ERROR!!!
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Mid'

Commented:
When I said it works fine, I was looking at the right side of the equation (which is fine).

You can't use Mid() as an assignment in asp.  You'll have to append inside a loop or something similar instead.

For example:

HexStr="414243"
Temp = ""
I = 1
Do While I <= Len(HexStr)/2
Temp = Temp & Chr("&H" & Mid(HexStr, I * 2 - 1, 2))
I = I + 2
Loop
Response.Write(Temp)  <--- Produces "ABC"

Experts Exchange Solution brought to you by