Solved

Long Dim error in classic ASP code

Posted on 2009-04-10
7
678 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
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Classic ASP + JS 4 67
Autosum input type=text when checkbox is true 28 71
UTC (timezone) without using an API 16 28
asp syntax 3 25
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now