.net :: Porting VBA Function Parameter Is Possibly Multidimensional Array?
Aug 26, 2009
I am porting Excel VBA to VB.NET. I have a function that takes a selection of data, and it may be one dimensional or two. VBA code is quite fluid about using a variable as either a 1-D or 2-D array, but VB.NET marks it as an error.
Here is the reduced code:
Public Function Stat(ByVal Data As Range) As Object
Dim Y() As Object
[code]....
View 2 Replies
ADVERTISEMENT
Oct 29, 2010
I have a multidimensional array (not jagged array) that saves data from rows and columns of an excel spreadsheet. After it completes recording the data from Excel, I need to pass the array to another function.I understand how to pass a jagged array, but not a true multidimensional array.
Can someone point me in the right direction? I've done some searching on this site, and others, but most of the info only includes single dimension arrays or jagged arrays.
View 1 Replies
Apr 30, 2009
I am trying to use a simple quicksort routine for a multidimensional array but cannot figure out the syntax. I am stumped because it works fine in VB6 but no luck in .Net
Array Declaration:
Dim sArrIn(25000, 3) As String 'sort key (pkg, kitting, zip), kitting, data
Function Call:
[Code]....
View 4 Replies
Feb 6, 2012
I have a Sub with an array of strings as parameter:
Private Sub des(ByVal array() As String)
Dim i As Integer
For i = 0 To UBound(array)
[code]....
When I call the function inside my main function , the value of str changes even if the array is passed to the function Byval
Dim str() As String
str = {"11111", "22222", "33333", "44444", "5555", "66666"}
des(str)
I tried making a copy of the array in the Sub, but it still changes in the main function
Private Sub des(ByVal array() As String)
Dim i As Integer
Dim array2() As String
[code]....
I read on a site that you cannot pass arrays ByVal ,is this true? If so , how should I proceed?
View 3 Replies
Dec 7, 2010
I would like to pass array to function as parameter. Here is an example for variable that is not array:
[Code]...
View 5 Replies
Jan 20, 2012
I have a Sub with an array of strings as parameter:
Private Sub des(ByVal array() As String)
Dim i As Integer
For i = 0 To UBound(array)
[code].....
View 1 Replies
Sep 24, 2009
I'm working on porting some classic VB6 code to C# and just stumbled across a usage of the PV function.I feels wrong including a reference to the Microsoft.VisualBasic Assembly. Is this something that is commonly done, or should I explore further options. The next idea that pops into my mind is exploring this PV function in Reflector.
View 3 Replies
Apr 21, 2011
Is it possible to create a routine in VB.NET with a name-based parameter array? The WebMethod attribute built into the framework is used exactly this way: WebMethod(BufferResponse:=False)
Specifically, I'd like to use it in a class' constructor. I'd like something similar to this:
New MyObject(id:=10,buffer:=True)
I'm not even sure what the terminology is for this kind of parameter list, so I can't even find it when searching.
View 2 Replies
Mar 9, 2011
I want to have a "template" function that can receive different parameter and a type parameter, like:[code]But Vb told me that tupeList is not defined... is there a way I can do that?
View 2 Replies
Jun 22, 2012
I have a multidimensional array which will hold 3 bits of value and value will be added through a loop by reading from db. When it come this line of code:
*MenuAccess(.Fields("GROUPNO").Value, .Fields("ITEMNO").Value, .Fields("SUBITEMNO").Value) = OKNO*
It's hitting error, 'Object reference not set to an instance of an object.'
Public MenuAccess(100, 30, 50) As Boolean
Private Sub RtGetMenu_Access()
Try
[Code]....
View 1 Replies
Jun 7, 2009
Hi can someone show me an example of a multidimensional associative array in vb.net. Need array to hold peoples name, there age and a few other settings. Want to be able to use a Dictionary to use People.Add.
View 1 Replies
Apr 16, 2009
I've got a 3-dimensional array that I'd like to clear.
View 1 Replies
Mar 17, 2010
I'm writing a game in visual basic 2008 and things are going fairly well with it for the most part.. well until today.. I can declare a 1 dimensional array of a class just fine but cannot for the life of me get the syntax right for a multidimensional array. I usually don't have many issues in writing in VB but this is the first large scale program I have ever written in VB2008 and the 1st large scale uses of classes in VB as well
Here is my code to better illustrate my problem here is the class..minus most of the properties Public Class Objectives private zone as Integer private TZone as integer Public Property TargetZone As Integer Get Return TZone End Get Set(ByVal value As Integer)
[Code]...
View 2 Replies
Oct 23, 2009
I'm very new to VB.NET and I suppose this is a little big for a first project.I've done the same thing in other languages so I figured it wouldn't give me much trouble.I'm working on a map editor program for a 2D platformer game.The map will be an array of a structure which contains the width, height, and tile elements of each layer. the tile elements are stored in a 2D array within the structure.[code]That didn't give an exception but I'm not sure that it actually redimmed considering the second assignment command still crashed.
View 1 Replies
Nov 8, 2011
I am writting a vb.net program that I want to read in data from Excel and then populate a multidim array with it.I have been able to import the Excel data into a DataGridView (haven't been able to go directly to an array). Now I am trying to loop through the DataGridView to populate the array.This is were I am having troubles.[code]
View 2 Replies
Sep 23, 2011
vb.net 2005.
I have profitMarginArray(29,3) <29 is actually a variable, but figured I'd put in a number for the example> and what I need is to retreive elements 0 and 3 sorted on 3 in some way shape or form. The biggest problem is element 3 isn't unique so there could be 5 that have the same value (56.34 for instance) so a sorted list is out.
The current array could look something like
Item1, .34, .75, 54.67
Item2, .32, .75, 57.33
Item3, .29, .5, 42
[Code]....
View 5 Replies
Apr 15, 2012
Is there at all a way to sort (numerically) a multidimensional array?
I have an array that is as follows `dim points(23,1) as String`
The first dimension of the array has the players names in, the second dimension of it has their cumulative points, so I want to sort the array by points and maintaing the correlation of players name to points
View 5 Replies
Dec 12, 2010
* I posted this in VB forum at first by accident instead of .Net* I am trying to create a console application that computes the row and column sum and prints the elements with the resulting sums for each row and column.
[Code]....
My column sum code is currently showing the row sums. I need the column sums to display in descending order. So i know it would require a sorted array, but i'm not sure how to go about doing that given i can't get the correct values to show up. So I would need it to display as "Column sums are 12, 20, 13, 24, 51. " and then the next line would be "Column indexes are 1, 3, 2, 4, 5."
View 4 Replies
Nov 23, 2010
I'm trying to build up a multidimensional array which will hold two bits of info for each record in a database e.g. id, description.[code]...
View 2 Replies
Mar 23, 2010
I need to count number of repeating and position where they repeat of all number in multidimensional array like this:
1 2 1
1 1 2
2 3 1
And result need to be:
Number 1- two times on position 1, one time on position 2, two times on position 3
Number 2- one time on position 1, two times on position 2, one times on position 3
Number 3- 0 on position 1, one time on position 2, 0 on position 3
View 2 Replies
Mar 16, 2011
if i have a multidimensional array:
dim test(,,) as string
how can i loop through the array to find if another variable is contained in the second dimension of the array
dim x as integer = test.indexof(OtherVariable)
obviously above won't work
View 4 Replies
Mar 4, 2011
If I have the following array:
Dim Array(4, 10) As String
Array(0, 0) = "100"
Array(0, 1) = "200"
[code]....
How do I get the following count:
0 = 2
1 = 4
View 3 Replies
Dec 20, 2011
I can't seem to get the code structure I'm looking for when importing a csv file into an array. The CSV format in question is 69 columns, and unknown rows since it depends on the time length of the data capture. Over the past 3 days I have tried many methods and can output it all to a listbox, as shown below (column headers appear in order), however when I try to put it into an array it only reads the first column. Am I missing something in the declaration of the array, or do I need to use an arraylist? Every permutation doesn't seem to get the results I seek, or I just plain crash the program.
[Code]...
View 6 Replies
Jul 12, 2011
I have a 2 dimensional array and also a 2 column listview box. I am able to insert array (0,i) into column A, but i do not know how to insert Array(1,i) into column B.
[Code]...
View 4 Replies
Mar 26, 2012
I am trying to make a jagged array that has,
3 columns
with 5,4,4 rows respectively
that each have 2 rows
that have a varying number of rows, for example 6,9,5,6,4 I have the first part setup but I don't know how to get to another level of the jagged array.
Dim potentialStructure()() As Short = {New Short() {0, 1, 2, 3, 4}, New Short() {0, 1, 2, 3}, New Short() {0, 1, 2, 3}}
And how would I access an element at say, the lowest level?
View 1 Replies
Oct 3, 2009
Dim array1(9,2) as String
So basically, 10 rows and 3 columns and say I want to sort them by the values in the 3rd column.
Each row is essentially a record of data and must be kept together.
Now I know that you can't use the array.sort method but would I have to use a bubble sort or something for this?
What's a good way to manipulate the records while still keeping each row linked together somehow.
View 5 Replies
Dec 12, 2010
I am trying to create a console application that computes the row and column sum and prints the elements with the resulting sums for each row and column.[code]My column sum code is currently showing the row sums.and the rowsum code is showing a continuous sum, rather than a sum for just that row.
View 4 Replies
May 15, 2012
First time I've had occasion to do this, but how would you represent the data in a SQL database table in a multidimensional array? I've heard tell of multidimensional arraylists but have no idea how to use them.
Here's what I have -
The table is 15 columns across and a varied amount of rows depending on the query.
rawData is an arraylist. finalData is an array.
Dim myReader As SqlDataReader = sqlcom.ExecuteReader
While myReader.Read()
[Code].....
Obviously, this gives me a long list of all the data from the query. I want to break it in rows.
View 8 Replies
Jul 12, 2011
I am trying to initialize a multidimensional array. Here is my syntax; this does not create errors but it does not store all values either. Although it correctly prints out all records in this snippet,
dFirstWeek = CDate(FirstWeek)
dFirstWeek = DateAdd(DateInterval.WeekOfYear, -1, dFirstWeek)
Dim dFirstDay As Date
Dim arrWeekYear(5000, 1) As Date
Dim i As Integer = 0
Dim j As Integer = 0
[Code] .....
But this time, only one "j" record appears per "i" record. Why is this? And then after these few records, many dates resembling null dates appear: "1/1/0001". So why do all records appear in upper section, but not from lower? Did I insert values wrongly into this array? And it does not have to have fixed number of rows, just a fixed number of columns.
View 3 Replies
Jan 1, 2011
Is there any way to create a multidinensional array that contains arrays of different lengths (similar to nesting arrays of different lengths in python).
Because if I were to declare a variable Dim accounts(2,2) As Integer all 1D arrays at each dimension have the same length. Is there any way to create an array so that this is not the case?
e.g The above code would create an array like this:
[[0,0],[0,0]]
but would it be possible to create this:
[[0,0],[0,0,0]]
View 3 Replies