[ASP.NET of VB.NET]Functie die array returnt

Pagina: 1
Acties:
  • 46 views sinds 30-01-2008

  • mistercash
  • Registratie: Juli 2004
  • Laatst online: 19-03 14:18
Dit is wat ik heb in een functie:

code:
1
2
3
4
5
function Getuserfunction() as string() ' This Function will get the function of the user
    dim arrayinside() as string
    arrayinside(0)="foo"
    return(arrayinside)
end function

Dan in roep ik de functie op zo:
code:
1
2
3
dim strtest(5) as string
strtest=Getuserfunction()
con_close.text=strtest(0)

Dan krijg ik deze error:
System.NullReferenceException: Object reference not set to an instance of an object.

Kan iemand mss zeggen hoe ik juist een array kan returnen?

Verwijderd

code:
1
dim arrayinside as string()

I.p.v.
code:
1
dim arrayinside() as string

?
En op welke regel krijg je de NPE?

  • whoami
  • Registratie: December 2000
  • Laatst online: 17:14
Je krijgt die nullpointerexception gewoon omdat je die array niet gealloceerd hebt.
In C#:
code:
1
string[] theArray = new string[4];

bv, hier maak je een array waarin 4 strings kunnen.

Dit is gewoon ff in de manual kijken hoe je een array maakt in vb.net

https://fgheysels.github.io/


Dit topic is gesloten.