Solved

Long Dim error in classic ASP code

Posted on 2009-04-10
7
706 Views
Last Modified: 2012-05-06
In classic asp, I am trying to add 32813 + 8000 together and store it into a variabl - because it is over 32767, it is rolling the answer to 42813 instead of 112813.. so I'm trying to declare a LONG variable to handle it, but I'm getting an error trying to declare a long variable:

Microsoft VBScript compilation error '800a0401'
Expected end of statement
/resmgr/test_long.asp, line 8
Dim NewI as Long
---------^

HELP! Can someone help me figure out how I can do this?

<%@ Language=VBScript %>
<% Option Explicit %>
 
<!--#include file="loggedin.asp"-->
<!--#include file="dsn.asp"-->
<%
 
Dim NewI as Long
Dim ThisI
Dim iList
 
NewI = 32813
response.write "invoice=" & NewI
 
thisI = clng(NewI) + 8000
 
response.write "<br>thisI=" & thisI
%>

Open in new window

0
Comment
Question by:bawalker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Assisted Solution

by:Aanvik
Aanvik earned 50 total points
ID: 24118294
Don;t use As long.

Try this and it should work.
Dim NewI
Dim ThisI
Dim iList
0
 

Author Comment

by:bawalker
ID: 24118362
If I remove the "as Long" it gets me back to my original problem where trying to add 32813 + 8000 and save it into a variable gives me the wrong answer..  I need to store the answer in a variable somehow.. how can I do that and get the correct answer?
0
 

Author Comment

by:bawalker
ID: 24118426
Here is my latest code - and here is the result:

Starting number = 32813
32813 + 8000 = 40813
<%@ Language=VBScript %>
<% Option Explicit %>
 
<!--#include file="loggedin.asp"-->
<!--#include file="dsn.asp"-->
<%
 
Dim NewI
Dim ThisI
Dim iList
 
NewI = 32813
response.write "Starting number = " & NewI
 
thisI = clng(NewI) + 8000
 
response.write "<br>32813 + 8000 = " & thisI
%>

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 15

Accepted Solution

by:
spprivate earned 100 total points
ID: 24118712
Dim i
Dim s

i=CLng(32813)
s=i+CLng(8000)
Response.Write(s)

THis works correctly
0
 
LVL 15

Expert Comment

by:spprivate
ID: 24118718
Infact your result is correct.So what is the issue?
0
 
LVL 14

Assisted Solution

by:pteranodon72
pteranodon72 earned 100 total points
ID: 24119112
spprivate is right:
32813 + 8000 = 42813

You might expect
32813 + 80000 = 112813

I think you just have a typo in your constant.
A rollover issue would have given you a negative result.

pT

0
 

Author Closing Comment

by:bawalker
ID: 31569022
OMG - guess that's what I get for staring at code for too long - LOL - after changing from CINT to CLNG, I had fixed the problem and didn't even realize it - you are all right I accidentally thought it should be 112813 - what a difference a zero can make :-)  Thx to all of you - great teamwork!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question