.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 28th, 2004, 09:58 PM
dav dav is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 dav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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??

Reply With Quote
  #2  
Old April 29th, 2004, 07:09 PM
funkyonex funkyonex is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 funkyonex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > returning array form vb.net function


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap