i get a "subscript out of range" on the following code the second time it runs. the first time it's ok... (error on the last line) - Dim arrFAB() As Variant
-
Dim rows As Integer
-
-
Private Sub cmdAdd_Click()
-
rows = rows + 1
-
ReDim Preserve arrFAB(1 To rows, 1 To 5)
2 2032
Hi,
In VB6, When using "Preserve" with arrays , Only the upper bound of the last dimension in a multidimensional array can be changed.
If u change any of the other dimensions, or the lower bound of the last dimension, you will get this run-time error .
Instead Use one more array . Read This
REgards
Veena
Hi,
In VB6, When using "Preserve" with arrays , Only the upper bound of the last dimension in a multidimensional array can be changed.
If u change any of the other dimensions, or the lower bound of the last dimension, you will get this run-time error .
Instead Use one more array . Read This
REgards
Veena
ok, i used a dummie array to turn everything around, and it worked. this is how i did it: -
Dim arrFAB() As Variant
-
Dim rows As Integer
-
-
Private Sub cmdAdd_Click()
-
' This sub adds one more item to a list box of items to purchase
-
Dim arrDummie() As Variant
-
Dim i, j As Integer
-
Dim totalprice As Double
-
-
rows = rows + 1
-
-
ReDim Preserve arrFAB(1 To 5, 1 To rows)
-
ReDim arrDummie(1 To rows, 1 To 5)
-
-
arrFAB(1, rows) = txtFAB.Text
-
arrFAB(2, rows) = txtDescription.Text
-
arrFAB(3, rows) = txtQty.Text
-
arrFAB(4, rows) = txtUnitPrice.Text
-
arrFAB(5, rows) = CInt(txtQty.Text) * CInt(txtUnitPrice.Text)
-
-
-
For i = 1 To rows
-
For j = 1 To 5
-
arrDummie(i, j) = arrFAB(j, i)
-
Next
-
totalprice = totalprice + arrFAB(5, i)
-
Next
-
-
lstItems.List = arrDummie()
-
txtTotalPrice.Text = totalprice
-
cmdCreate.Enabled = True
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: TLOlczyk |
last post by:
I have a brain cramp and I need some help.
I have a chunk of code below which demonstrates
a problem I have with multidimensional arrays.
I want to keep it simple but something specific is...
|
by: Kevin |
last post by:
Help!
Why are none of these valid?
var arrayName = new Array();
arrayName = new Array('alpha_val', 1);
arrayName = ;
I'm creating/writing the array on the server side from Perl, but I
|
by: Charles Banas |
last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to
get some opinions and comments on it, hopefully so i can gain some
sort of insight as to why this works.
at the top of the...
|
by: Mark Smith |
last post by:
I'm trying to copy data from a 1D array to a 2D array.
The obvious thing doesn't work:
int twoDee = new int;
int oneDee = new int { 1, 2 };
Array.Copy(oneDee, 2, twoDee, 2, 2);
This causes a...
|
by: chris |
last post by:
Hi there,
I created a Multidimensional array of labels
Label lblMultiArray = new Label { {Label3, LblThuTotal},
{Label4,LblFriTotal} };
Now I would like to compare the values in the array,...
|
by: |
last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to...
|
by: Chuy08 |
last post by:
If I have a multidimensional array like the following:
Array
$records =Array
0 = 30 year, 6.0;
1 = 30 year, 6.0;
2 = Pay Option, 1.0;
3 = Pay Option, 1.0;
How could I flatten this to...
|
by: LittleCake |
last post by:
Hi All,
I have a multidimensional array where each sub-array contains just two
entries, which indicates a relationship between those two entries. for
example the first sub-array:
=Array
(
=30...
|
by: Jezternz |
last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
|
by: Slain |
last post by:
I need to convert a an array to a multidimensional one. Since I need
to wrok with existing code, I need to modify a declaration which looks
like this
In the .h file
int *x;
in a initialize...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |