Solved

# val function in asp

Posted on 2003-12-12
2,213 Views
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.
0
Question by:MAXMASTER
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 42

Expert Comment

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

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

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

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

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
###### Suggested Courses
Course of the Month7 days, 1 hour left to enroll