Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

x = x + 1 gives illegal character

Status
Not open for further replies.

mbutler55

Instructor
Feb 5, 2003
33
US
I have had some WONDERFUL help on some previous questions this morning from
jlsmithprism
BDC2
FesterSXS
just to name a few helping me with several issues. I am now down to this one BIG BUG!!!! I have taken out ALL of my code except for the following:
<%@ Language=VBScript %>
<%
Option Explicit
Dim iNumRec
iNumRec = 0
   iNumRec = iNumRec + 1
response.write (iNumRec)
%>
I keep getting illegal character for the line iNumRec = iNumRec + 1. Please someone tell me what is happening before I go back to pen and paper instead of a computer.

You can see all that has been tried at thread333-469008.
 
My first question is why are you using

Option Explicit
Dim iNumRec

in ASP?

You do need to do this

just say
<%@ Language=VBScript

iNumRec = 0
iNumRec = iNumRec + 1
response.write (iNumRec)%>
 
My first question is why are you using

Option Explicit
Dim iNumRec

in ASP?

Out of curiousity of coming up with this statement Why??


This
<%@ Language=VBScript %> is not needed
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
If you're going to use Option Explicit, it must be the first thing on the page. try this:

<% Option Explicit %>
<%@ Language=VBScript %>
<%
Dim iNumRec
iNumRec = 0
iNumRec = iNumRec + 1
response.write (iNumRec)
%>
=========================================================
if (!succeed) try();
-jeff
 
I'm sure Option Explicit is a preference. I personally like it as it keeps me from accidentally typing an incorrect variable name. I did in fact get the necessary code in question working. Still don't know what the cause of the error is/was. I was actually working on getting a Median function for ASP from an Access database. But all is well and working and I do use OE and I did get x = x + 1 to work.
 
Try &quot;forcing&quot; iNumRec to be an integer

iNumRec = cint(iNumRec) + 1

I know this looks trivial, seeing that you have already stated that iNumRec = 0, but I have seen stranger things happen and sometimes ASP get a bit confused when working with mathematical processes.

 
Sounds like tschonken's solution should work (perhaps vbScript is thinking of iNumRec as a boolean...???)

Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Hallo,

For my 2 penneth, I always use Option Explicit and Dim my variables (oohh eerr, missus) as it's good programming practice :)

- Frink
 
I agree with using Option Explicit in the VB environment and also in VBA but I have never heard of it being used in ASP. I tried a test in ASP using Option Explicit and it doesn't do anything in ASP. At least that I can see.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top