I am trying to do a substring on the contents of one of my database cells. I am currently trying:
hold = Mid(cstr(other("Material")),0,2)
where other("Material") is the reference to the cell.
Any suggestions would be greatly appriciated.
qlipoth
9:07 pm on Jun 23, 2005 (gmt 0)
In ASP, Mid is 1-based
Try:
hold = Mid(cstr(other("Material")),1,2) or hold = Mid(cstr(other("Material")),1,3) if you are trying to get 3 characters.
webworker us
12:19 pm on Jun 24, 2005 (gmt 0)
Thanks. I'm so used to starting with zero from C++ and Java I didn't even think of it.
qlipoth
8:12 pm on Jun 24, 2005 (gmt 0)
Personally, I like Left(String, length) instead of mid... I'm lazy enough that one extra parameter bothers me.
mattglet
1:38 am on Jun 25, 2005 (gmt 0)
Left() and Mid() are apples and oranges. Mid() is way more powerful. It's not about laziness, it's about necessity.
giggle
8:44 am on Jun 28, 2005 (gmt 0)
If you want the end of a string you don't have to specify the last parameter with the MID verb.
E.g. to get "MICK" from strDescription = "FATMICK" you just need to specify:
strWhoIsFat = MID(strDescription,4)
Just thought that I'd share that, it has saved me a little bit of time now and then.
Mick
mrMister
1:52 pm on Jul 1, 2005 (gmt 0)
Thanks. I'm so used to starting with zero from C++ and Java I didn't even think of it.
Have you thought about using JScript instead of VBScript? It'll save you from all sorts of problems like this. Just put the following line at the top of your page...
<%@ Page Language="JScript"%>
webworker us
6:24 pm on Jul 1, 2005 (gmt 0)
I've thought of it, but decided to keep my stuff to one language. I have other people that edit the page, and use things like ASPmaker, and they would have difficulties if I use JScript.