Solved

val function in asp

Posted on 2003-12-12
4
2,159 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now