We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

type mismatch with the MID function

Bob Butcher
Bob Butcher asked
on
Medium Priority
309 Views
Last Modified: 2008-03-10
I cannot figure this out.

I have a string called mmsg. I want to test to see if I have a CRLF as the char and have the code as follows:

dim i
dim mmsg

mmsg = request.form("message")

for i = 1 to len(mmsg)
       if asc(mid(mmsg,i,1)) = 13 then
            response.write blah,blah,blah"
       end if
next

I keep getting a type mismatch on the line that has the mid(mmsg,i,1) and I know that there is data in mmsg and the len(mmsg) is working correctly because I am able to write out it's contents before I get into the loop.

Any one know why? I am stumped.
   
Comment
Watch Question

Lee W, MVPTechnology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
Why not just use instr?

If Instr(Request.form("message"), vbCrLf) > 0 Then
    'A CRLF character was found
End If

If you JUST want the CR character, use vbCr
Bob ButcheriSeries Engineer

Author

Commented:
The problem is I need to read the data and if there is a vbCR found, then I need to substitute it with a <br><br> because I am going to store it in a database and if it needs to be read in the future, then I need to have the breaks in the string.
Technology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013
Commented:
No problem... use replace.

When storing it in the database, reference it as Replace(Request.Form("message"), VbCrLf, "<br><br>")

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Bob ButcheriSeries Engineer

Author

Commented:
Thank you. The REPLACE worked great. I appreciate your help. Always is nice to have another person's point of view :-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.