Solved

val function in asp

Posted on 2003-12-12
4
2,188 Views
Last Modified: 2007-12-19
How do I use "VAL" function is asp?
this code here works in vb but not on asp
Please Help.

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

Thank you.
0
Comment
Question by:MAXMASTER
  • 2
  • 2
4 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 9929783
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.
0
 
LVL 1

Author Comment

by:MAXMASTER
ID: 9930487
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'

0
 
LVL 42

Accepted Solution

by:
frodoman earned 125 total points
ID: 9930669
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"
0
 
LVL 1

Author Comment

by:MAXMASTER
ID: 9931315
Ok I will give you the points but I cant use that code anymore because it somewhat give me a wrong value

anyway thank you for your help

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question