|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
optional array problemThe following syntax works when used within a subroutine but not when declaring an optional parameter in a sub definition: Within sub: Dim arr(,) as integer = {{0}, {0}} Declaration: Private Sub TempName(byval field1 as string, optional byval arr(,) as integer = {{0}, {0}} ) The Sub Declaration put a squiggly mark under the first { and states "expression expected". I've tried different variations and searched books and the web to no avail. Is this a bug or am I using incorrect syntax? Thanks! NJ The default value for an optional parameter must be constant. An array is
not considered a constant. -- Show quoteDavid Anton www.tangiblesoftwaresolutions.com Instant C#: VB.NET to C# Converter Instant VB: C# to VB.NET Converter Instant J#: VB.NET to J# Converter Clear VB: Cleans up outdated VB.NET code "Still Learning" wrote: > Hi, > > The following syntax works when used within a subroutine but not when > declaring an optional parameter in a sub definition: > > Within sub: > > Dim arr(,) as integer = {{0}, {0}} > > Declaration: > > Private Sub TempName(byval field1 as string, optional byval arr(,) as > integer = {{0}, {0}} ) > > The Sub Declaration put a squiggly mark under the first { and states > "expression expected". I've tried different variations and searched books and > the web to no avail. Is this a bug or am I using incorrect syntax? > > Thanks! > NJ |
|||||||||||||||||||||||