473,574 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array blowing up

For some reason, when I try to run the following array, I'm getting an
error:
dim cat(0)

cat(0)="0407"
cat(1)="0102"

'I will be adding more to this array, but just trying with two for
starts.

for counter = 0 to 1

itno=cat(counte r)

'I get an error when it runs through this function

Function rightvar(theVar ,lengthNeeded)
Dim sResult
sResult=theVar
if Len(theVar)< lengthNeeded then sResult= String(lengthNe eded -
Len(theVar)," ")& theVar
rightvar=sResul t
End Function
Can someone help me understand why?

Thanks.
Jul 19 '05 #1
2 1492
You created an array to hold one item, but are filling it with two items,
perhaps that's why the error. Try

Dim Cat(1)

The "1" represents the maximum, zero-based, index you can have in the array.
In this case 1 means 0, 1 = 2 items.

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Bill" <bi***********@ gospellight.com > wrote in message
news:8d******** *************** ***@posting.goo gle.com...
For some reason, when I try to run the following array, I'm getting an
error:
dim cat(0)

cat(0)="0407"
cat(1)="0102"

'I will be adding more to this array, but just trying with two for
starts.

for counter = 0 to 1

itno=cat(counte r)

'I get an error when it runs through this function

Function rightvar(theVar ,lengthNeeded)
Dim sResult
sResult=theVar
if Len(theVar)< lengthNeeded then sResult= String(lengthNe eded -
Len(theVar)," ")& theVar
rightvar=sResul t
End Function
Can someone help me understand why?

Thanks.

Jul 19 '05 #2
> Function rightvar(theVar ,lengthNeeded)
Dim sResult
sResult=theVar
if Len(theVar)< lengthNeeded then sResult= String(lengthNe eded -
Len(theVar)," ")& theVar
rightvar=sResul t
End Function


That's the oddest indentation scheme I've yet seen.

As for your errors, read up on Dim, ReDim and ReDim Preserve...
http://msdn.microsoft.com/library/en...l/vsstmdim.asp
http://msdn.microsoft.com/library/en...vsstmredim.asp

....and then tell us what kind of error you get when trying your rightvar
function.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2768
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
575
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a print_r cmd any suggestions would be great. Thanks much Todd //avShed array Array ( => Array ( => 1 => 08:00 ) => Array ( => 1 => 08:05 ) ...
15
5164
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
1
1973
by: youngdubliner | last post by:
I'm having a problem ........ I've stripped all my code to help isolate the problem. Its seems to be with importing numarray when python is embedded in C. I have a simple C program it Opens Python imports a script and then Closes Python like so .......
2
4255
by: James | last post by:
Hi, I am using Visual C++ 6.0. I got a "stack overflow" error message when running the program because of a "double array". I have a computer with 1GB memory. Can I extend the memory for the program running? How? Looking forward to hearing from you! Regards,
5
1525
by: WesIdell | last post by:
Hi All: I need some advice regarding a problem that I'm experiencing. I'm using a group of TextBox controls in the .aspx page and am using a function in the .cs code to perform some actions with the values. The problem is that when I try to retrieve the Text property, it is always equal to "" (an empty string) even though that a value is...
2
2250
by: Kristopher Wragg | last post by:
I'm having some serious problems with the TreeView control. I've got a control that inherits TreeView and has some methods that firstly create a TreeNode then does some recursive procedure to add all the children from a database of a sort. Then once this is complete I clear the nodes, then add the TreeNode so it should be the only root...
6
3894
by: rbutlerjr | last post by:
Hi, I've racked my brain for the last few hours trying to figure this one out. I have an array of language strings such as : $lang = array(); $lang = 'hello'; $lang = 'goodbye'; $lang = '1st'; This is being used by an ajax routine, so I don't know which string will be requested at runtime. So, I've got $lang and a request
6
1239
by: ssecorp | last post by:
def fib(n): def fibt(a, b, n): if n <= 1: return b else: return fibt(b, a + b, n - 1) if n == 0: return 0 else: return fibt(0, 1, n);
0
7797
marktang
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...
0
8225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6440
agi2029
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...
1
5611
isladogs
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...
0
3739
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3748
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2233
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
1
1333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1053
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.