...., Optional ByVal avarText2() As String =?????)

  • Thread starter Thread starter SamSpade
  • Start date Start date
S

SamSpade

....., Optional ByVal avarText2() As String =?????)



The above is an argument in a function declaration.

I can't finish it because I don't know how to spcify a literal string array.
I tried {""} but the compiler complains.

Nothing seens to wotk but I'd like a one dinensional array with one element
= " "



Many Help examples but all C#



Any suggestions?



Cal
 
Ease, don't use optional, use overloaded methots instead. Like thi:

Public Function MyFunction(ByVal parm1 As String, ByVal parm2() As
String) As Integer
Return -1
End Function

Public Function MyFunction(ByVal parm1 As String) As Integer
Return MyFunction(parm1, Nothing)
End Function


HTH
Brian W
 
Use a ParamArray and not optional:

Private Sub Test(ByVal ParamArray avarText2() As String)
If avarText2.Length = 0 Then
'---Array was not sent
Else
'--- Array was sent
End If
End Sub
 
* " SamSpade said:
Thanks I'll do that but I wonder why {" "," "} doesn't work>

I wonder too... You can write 'Optional ByVal s() As String = Nothing'.
 
Actually I had that. If there was always something there the code would be a
little simpler (actually very little simpler).

Guess I'll never get rid of habits formed when assembly programming for 4K
ROMs where every byte counted.

Cal
 
* " SamSpade said:
Actually I had that. If there was always something there the code would be a
little simpler (actually very little simpler).

I am missing the feature you "requested" too...

:-)
 
Back
Top