?
Solved

Long Dim error in classic ASP code

Posted on 2009-04-10
7
Medium Priority
?
712 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 150 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Accepted Solution

by:
spprivate earned 300 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 300 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

765 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