• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

type mismatch with the MID function

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

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.
  • 2
  • 2
1 Solution
Lee W, MVPTechnology and Business Process AdvisorCommented:
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
samic400Author 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.
Lee W, MVPTechnology and Business Process AdvisorCommented:
No problem... use replace.

When storing it in the database, reference it as Replace(Request.Form("message"), VbCrLf, "<br><br>")
samic400Author Commented:
Thank you. The REPLACE worked great. I appreciate your help. Always is nice to have another person's point of view :-)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now