PDA

View Full Version : Strange type mismatch


dominicall
06-08-2003, 05:55 PM
When is a string not a string??? According to my replace function below when it is a string???

Can anyone see why on earth this is giving a type mismatch???

For i = 1 To Cols

'replace mm2 with superscript version
Dim mm2pos, columnhead2, columnheading
columnhead2 = CStr(Request.Form("columnhead")(i))
mm2pos = InStr(columnhead2,"mm2")

'debug
Response.Write columnhead2 & "<br>"
Response.Write mm2pos & "<br>"

If mm2pos > 0 Then
columnheading = Replace(columnhead2,"mm2","mm<sup>2</sup>", , ,vbTextCompare)
Else
columnheading = columnhead2
End If

... do some other stuff here...

Next

It's throwing the error on the replace statement... for reference, the value I entered in the appropriate field was Size (mm2).

Hope someone can see this.

Thanks

dominicall

raf
06-08-2003, 09:22 PM
Question1: why use the replace function instead of the replacemethod here? + it should probably be
Replace(columnhead2,"mm2","mm<sup>2</sup>", 1,-1 ,1)
Question 2: "value I entered in the appropriate field was Size (mm2)." --> does this mean the replace creates something like '123 (mm˛)' ? Did you try without the () ?

dominicall
06-09-2003, 10:09 AM
Thanks raf - took all the testing for mm2 out, left everything the same as it was and it worked...

dominicall :)