Make Function Which Return Jagged Array?
Apr 4, 2012Can we make function which return jagged array? If so, could u give example of it?
View 2 RepliesCan we make function which return jagged array? If so, could u give example of it?
View 2 RepliesI'm working on a program dealing with jagged arrays.Code is below.The FindPath() function works perfectly.It essentially randomly chooses an action from 3 possible choices.The goal of this function is to make it to position (3,3) from (0,0).Sometimes it makes it, sometimes it doesn't.It gives up after 2000 moves.
The PushButton() function is where I have the problem.I want to run the FindPath() function 2000 times, and return the resulting list of moves into intLists()(), my jagged array.I want to use
intRuns = 0
For intRuns = 0 To intLists.GetUpperBound(0)
lstMoveList.Items.Add(intLists(intRuns).GetUpperBound(0)) 'here is where I get the problem.
this section of code to dump the number of attempts it took into a listbox on the main window.I do this at the bottom of the FindPath() function, but that is for testing purposes only.I eventually want to take the successful attempts and manipulate those, so eventually I get the minimum possible number of movements to get from the starting point of (0,0) to the ending point of (3,3).
Function PushButton()
Dim intRuns As Integer
Dim intLists(2000)() As Integer[code]...............
So I have a function that looks up values in a jagged array, and it goes like this:
Private Function Lookup(ByVal Search_path As String) As Integer
Dim i As Integer = 0
Do Until MasterIndex(i) Is Nothing 'throws an exception here
[Code]....
Problem is, when I test this with an empty array, it gives me the error of Index was outside the bounds of the array at line 3. How do I fix this?
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?
Public Property TabsCollection()() as String()()
Get
Return _tabsCollection
End Get
[code]....
but it errors saying: End of statement expected.
Before adding rows to a table I am evaluating the SSN number. These will later be flagged for correction so I am setting a datatable column to true or false if it passed muster or not.
I wrote a function to check the number and make the determination plus pad it with zeros and hyphens where they should be. My problem is I want to return the results in an array. I am getting system.string[] as the return value.[code]...
I'm trying to write a function that returns an Array that I can pass into a String.Format[code]...
View 3 RepliesI want to return an array from a function.dt is a DataTable that is global
HTML
Dim dr As DataRow
For x As Integer = 0 To adoc.GetUpperBound(0)
dr = ds.Tables(0).NewRow()
[code].....
I'm definitely missing something here. I am trying to return an array forn the sql statement, chich I can reference as abom() in the original source.The ultuimate goal is to manually populate dt.
I'm trying to write a function that returns an Array that I can pass into a String.Format:
Public Function ToArray() As Array
Dim vals As New ArrayList()
vals.Add(Me("district"))
[code].....
I've this code, but there is a problem with setting values. I get "null object" error. how to work properly with functions.
Public Structure Results
Dim Nickname As String
Dim Result As Integer
[Code].....
Dim oList as new Hashtable
oList.Add("1","Value1")
How can I create a a function to return my objects like the above one.
[code].....
I'm trying to call a function from a sub, and have it return an array to the original sub.
I currently have:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Registry_GetUsers()
End Sub
[code]....
Which works, but I want to loop through each of the items in users from within the original sub, not the function, as it currently does.So I need to return the array to the original sub, so I can then iterate through it from there.
Public Function Foo() as String() Dim bar As String = {"bar1","bar2","bar3"}
Return bar End Function
My situation is similar to the code sample above where I'm returning a string array from a function.
What I would like to do is just return the string array without having to declare a variable first and then return the variable.Something like this, although this obviously doesn't work:
Return {"bar1","bar2","bar3"}
Is it possible to do this, I can't seem to find a method that works?
I have a class called Customer. It has some property like custID,custName..etc. Inside Customer class I have a function which returns an array of customer.
I wrote a function like this :
Public Function InitLoadCustomerDetails() As Customer()
sql = "SELECT* FROM tblCust"
ds = classDC.queryHandler(sql, "InitCustomerDetails")
Dim customerArray(classDC.maxrow - 1) As Customer
Dim currentCustomer As New Customer
[Code] .....
But it is not returning an array. Just a customer variable??
Public Function InitLoadCustomerDetails() As Customer()
Return customerArray
End Function
Fix this to return an array of customer!!
[code]...
Expected Results: A scalar result of the comparison between Array1 and Array2 such that when Array1>Array2 it is true. See expected array above.
Actual Results: When Result(x) is true, all elements become Array1(x) and Array2(x) .What is wrong with the function?
I have an abstract class in VB.NET. I want all classes that inherit from this class to return whatever value makes sense. For example, it could be an Decimal, Integer, String. How can I delcare the function in the abstract base class to allow for this? Is this even possible?
[Code]...
Currently I have written a function to deserialize XML as seen below.How do I change it so I don't have to replace the type every time I want to serialize another object type ? The current object type is cToolConfig. How do I make this function generic ?
Public Shared Function DeserializeFromXML(ByRef strFileNameAndPath As String) As XMLhandler.XMLserialization.cToolConfig
Dim deserializer As New System.Xml.Serialization.XmlSerializer(GetType(cToolConfig))
Dim srEncodingReader As IO.StreamReader = New IO.StreamReader(strFileNameAndPath, System.Text.Encoding.UTF8)
Dim ThisFacility As cToolConfig
[code]....
I need to make a list box with 2 reports in it. Then i need to make a function that wil return the name of selected report, or if no report is selected then return "no report selected".After i made the list box i tried to make the function in the code builder: insert procedure -> function. I tried using an IF statement to make it that when a report is selected the report shows as in a msg... but it keeps saying something is wrong with my code.
View 4 RepliesI have an requirement where I want to create a jagged array out of datatable and pass the jagged array over WCF.
Dim ObjJaggedArray(15)() As String
For Each row As DataRow In ObjTables.Tables(pKeyName).Rows
Try
'I DONT KNOW THIS PART
[code]....
I have a function to recursively search through windows (and their child windows) to find specific ones, it works exactly as expected, however it causes "function doesn't return a value on all paths" warning. This is the only warning in my entire program, and although it might be silly, I'm interested in knowing if there is a way to stop this error from occurring, but still allowing the function to work properly.[code]
View 4 RepliesI have a text file called COUNTERS_SETTINGS.DAT having the following contents:
[USERID]<=>COUNTER_1
[PASSWORD]<=>ADMIN1
[CONNECT_STRING]<=>DATA SOURCE=RECAT;USER ID=PAYOPER;PASSWORD=PAYOPER
I'm Trying to have that entries in a Jagged array of Strings like this
Array Name is : Core (2,1)
Core
(0) (1)
(0) USERID | COUNTER_1
(1) PASSWORD | ADMIN1[code]........
I'm working on a reporting section of code for an inventory app I'm making for my office.I call a text file, read every line into an array then populate information pages with what has been pulled from the text file.For reporting, I want to read every text file in the directory, reading each one into a multidimensional array.Thus I can call and report on each item, i.e.ItemArray(i,2) would be all systems with Windows 2008 EE..I have code that lists all files in the desired directory and counts each file, so I eventually get counts of how deep I need the first level of the jagged array to be. but not until after code execution. Basically how can I write each array of data to the jagged array.[code]But I get a null reference exception. "Use the new keyword to create an object instance".
View 8 RepliesI currently have a VB.NET dll that returns a jagged array of double. This is the declaration:
Public Function CalcMatching(ByRef dataArray1 As Object,
ByRef dataLen1 As Integer, ByRef dataArray2 As Object,
ByRef dataLen2 As Integer, ByRef matchingType As String) As Double()()
It works well inside VB.NET, but when I insert it into a VBA project, I noticed that after the execution of the funtion, while retrieving the data, the "Type mismatch' excpetion is raised inside VBA.I searched over the internet, but I could not find a delcaration of a jagged array inside VBA. is that possible? If yes, how can I do it?
Dim strTest(recordSet.Count)() As String[code]...
Then once the array i populated above, i need to find the if another variable is contained in the second dimension of the second paren contains the value of my variable like this.[code]...
I need to scan database and insert its values into an array. But I'm having some difficulties in handling null values and array.
The database looks like this:
0 1 2 3 4
30 31 32
33 34
36 37 38 39 40
38 39 47 48
I want to make array rr_item which gonna looks like this:
arr_item(1)={0,1,2,3,4}
arr_item(2)={30,31,32}
arr_item(3)={33,34}
arr_item(4)={36,37,38,39,40}
arr_item(5)={38,39,47,48}
Every code I've tried result in error everytime I tried to insert null value into any kind of c=variable, including array which I want to use. And I'm not quite sure with what I'm doing in jagged array I want to build.
sql_list = "SELECT * FROM retail"
oledbCnn = New OleDbConnection(connetionString)
Try
oledbCnn.Open()
[Code] .....
Okay I'm tring to make a fairly simple class
[Code]...
how do i declare jagged array? it has 7 elements consisting of 2 to 8 elements consisting of 3 elements.[Code]
View 1 RepliesI am trying to loop through a jagged array and keep getting an exception.
Dim jagged()() As Integer = New Integer(1)() {}
Dim test() As Integer = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}
For i As Integer = 0 To 1
[code]....
I have a question with jagged array, every element can contain strings, be empty or be nothing.
I would like to create a jagged array and put some strings into its cells.
Public Sub S1 ()
Dim MyArr(7)() As String ' OK
MyArr(1) = New String(8) {} ' OK the second cell contains 9 subcells
[Code].....
I have a scenario where I am trying to generate every combination of value from a jagged array - for example..[code]So all in first array associated with all in second array.I have created my jagged array with the values but I can't work out how to iterate through it and create all variations - I can iterate, but only get each value once at present.Also on a related note this could do with working in the case of more than 2 arrays - i.e. a multiple number of arrays within the jagged array.
View 3 Replies