Good day folks.
Within an ASP I'm working on I need to check whether an array is empty or
not.
Code:
Dim somearray()
'other code: array might have been populated, maybe not
if somearray() <> "" Then 'this is the line that hangs debugging using VID
'code if array is populated
else
'code if array is empty
end if
My problem is coming up when I debug(Using VID) I get this error:
An exception of type 'Microsoft VBScript runtime error: Subscript out of
range' was not handled.
But when I actually launch the page I don't get any errors. Of course if I
put in On Error Resume Next, and I run in debug mode I don't get any errors
through VID and I still obviously I don't get any errors launching the page.
Thanks for any insight from this ASP Newbie 3 15828
David,
You need to make sure you are not going beyond the array bounds, the error
you are getting is because you are not doing so.
Use the UBound() function that returns the last index within the array's
dimension. So, if the array contains 20 elements, the UBound function will
return 19.
lastIndex = UBound(someArra y, 1)
Look up the VB help for more info on the method.
--
Manohar Kamath
Editor, .netBooks www.dotnetbooks.com
"David P. Jessup" <davidATimntDAS HtechDOTcom> wrote in message
news:On******** ******@tk2msftn gp13.phx.gbl... Good day folks.
Within an ASP I'm working on I need to check whether an array is empty or not.
Code: Dim somearray() 'other code: array might have been populated, maybe not if somearray() <> "" Then 'this is the line that hangs debugging using
VID 'code if array is populated else 'code if array is empty end if
My problem is coming up when I debug(Using VID) I get this error: An exception of type 'Microsoft VBScript runtime error: Subscript out of range' was not handled.
But when I actually launch the page I don't get any errors. Of course if
I put in On Error Resume Next, and I run in debug mode I don't get any
errors through VID and I still obviously I don't get any errors launching the
page. Thanks for any insight from this ASP Newbie
VBScript's handling of array bounds checking leaves some to be desired. I
get inconsistent results with IsArray(somearr ay) depending on the state of
the array - GetRows on an empty recordset is a big culprit. What I've done
is write a function (I call it IsArrayEx, and it handles two dimensional
arrays which are what I work with most of the time) that works this way:
Function IsArrayEx(inArr ay, intUpperBound)
'--- this doesn't address whether or not there's data, only if the array
can be used
IsArrayEx = false
on error resume next
dim tmpVar
tmpVar = inArray(0, ubound(inArray, intUpperBound))
if err.number = 0 then
'--- the array is useable...
IsArrayEx = true
end if
End Function
"David P. Jessup" <davidATimntDAS HtechDOTcom> wrote in message
news:On******** ******@tk2msftn gp13.phx.gbl... Good day folks.
Within an ASP I'm working on I need to check whether an array is empty or not.
Code: Dim somearray() 'other code: array might have been populated, maybe not if somearray() <> "" Then 'this is the line that hangs debugging using
VID 'code if array is populated else 'code if array is empty end if
My problem is coming up when I debug(Using VID) I get this error: An exception of type 'Microsoft VBScript runtime error: Subscript out of range' was not handled.
But when I actually launch the page I don't get any errors. Of course if
I put in On Error Resume Next, and I run in debug mode I don't get any
errors through VID and I still obviously I don't get any errors launching the
page. Thanks for any insight from this ASP Newbie
WIlliam Morris wrote: VBScript's handling of array bounds checking leaves some to be desired. I get inconsistent results with IsArray(somearr ay) depending on the state of the array - GetRows on an empty recordset is a big culprit.
This has never failed me:
'open the recordset, then:
dim ar
if not rs.eof then ar = rs.GetRows
rs.close: set rs=nothing
if isarray(ar) then
'process data
else
'handle no-records event
end if
--
HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: FLEB |
last post by:
I have a function which should convey two things upon its completion.
First, the return value of the function, consisting of some text. Second,
it should convey an "error status", which, could be either a simple
"success", or a number of levels of failure.
(For the record, it's a logon script indicating success/failure, but I'll
probably use this elsewhere.)
The way I see it, I have a couple options, maybe more:
|
by: Marc S. Gibian |
last post by:
I am putting together a Perl tool to manage a large set of tasks
related to building a rather complex set of software. One of the goals
for moving to Perl is to provide very rigorous error checking and
handling. One area that has me puzzled is error checking some of the
file system operations. Just simple things such as open, rename,
unlink, print and some others ... all the sample code I've seen uses
them in a form of:
open(...) || die...
|
by: Flip |
last post by:
I'm reading the O'Reilly's Progamming C# book and I have a question about
array bounds checking. On page 174, near the top, they show an example
where c# does indeed to array bounds checking cause the example shows a
System.IndexOutOfRangeException being thrown. However, in the very next
section (Jagged arrays) they have warning section that says "Java
programmers take note: While Java does bounds checking on array use, C# does
not." ...
|
by: Maziar Aflatoun |
last post by:
Hi everyone,
I am reading and displaying data rows from my database where the first
column contains the Status checkbox. I like to enable my users to change
the status of individual rows by checking and unchecking the checkbox
column. I like to update the status in the database for the column where
the status was changed.
This is what I'm doing so far
|
by: jacob navia |
last post by:
Many compilers check printf for errors, lcc-win32 too. But there are
other functions that would be worth to check, specially memset.
Memset is used mainly to clear a memory zone, receiving a pointer to
the start, the value (most of the time zero) and the size of the
memory array to clear.
Problems appear when the size given is not the size of the object
given as its first argument. For instance
void fn(void)
| |
by: Hulo |
last post by:
In a C program I am required to enter three numbers (integers) e.g. 256
7 5 on execution of the program.
C:\> 256 7 5
There should be spaces between the three numbers and on pressing
"enter", further processing is done. The problem requires me to check
whether three numbers have actually been entered in the input line and
to warn if less or more numbers have been entered.
|
by: jacob navia |
last post by:
We hear very often in this discussion group that
bounds checking, or safety tests are too expensive
to be used in C.
Several researchers of UCSD have published an interesting
paper about this problem.
http://www.jilp.org/vol9/v9paper10.pdf
Specifically, they measured the overhead of a bounds
|
by: runway27 |
last post by:
hi
I am using MySQL - 4.1.22 when i use the following sql query
$result = mysql_query("SHOW tablename STATUS FROM databasename;");
i have also tried = $result = mysql_query("SHOW tablename STATUS FROM databasename");
i get the following error message
====================================================
|
by: Sudhakar |
last post by:
hi
I am using MySQL - 4.1.22 when i use the following sql query
$result = mysql_query("SHOW tablename STATUS FROM databasename;");
i have also tried = $result = mysql_query("SHOW tablename STATUS FROM
databasename");
i get the following error message
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |