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
Solved

Long Dim error in classic ASP code

Posted on 2009-04-10
7
690 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy only dates 3 91
Multiflying 2 Input Text On a Table 7 31
innerHTML 7 34
IIS components 2 15
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 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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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