|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
returning array form vb.net function
Hi I need to return an array of Decimals from a vb.net function.
The function simply takes in a string and then based on that string returns an array containing three decimals. The signature should look something like this: Public Shared Function foo(ByVal myString As String) As Decimal() dim returnArray(3) As Decimal if mystring ="hello" then returnArray(0) = 9.2 returnArray(1) = 4.5 returnArray(2) = 2.8 elseif mystring = "world" then returnArray(0) = 9.1 returnArray(1) = 4.2 returnArray(2) = 8.8 elseif mystring = "foo" then .... return returnArray End Function I want to use this function in the code behind of another page so that I can do something like dim decimalArray(3) As Decimal decimalArray() = foo("world") somelabel.Text = decimalArray(0) At the moment Im gettinig an error telling me 'Object reference not set to an instance of an object.' that sets the value of the label. any ideas?? |
|
#2
|
|||
|
|||
|
I just took the parenthesis off of the array assignment:
decimalArray = foo("world") And the code ran fine here. Set a breakpoint on the label.Text assignment and make sure your label control exists. HTH, -B |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > returning array form vb.net function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|