Solved

val function in asp

Posted on 2003-12-12
4
2,198 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
[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
  • Learn & ask questions
  • 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Suggested Solutions

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
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 get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

752 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