# Omitting the argument in Function

• June 20th, 2013, 04:10 AM
sinankrstarica
Omitting the argument in Function
I have a Function:

Private Function GetMask(gX As Integer, gY As Integer, gDirect As Integer, gLen As Integer) As String

If gLen > 0 Then
For i = 1 To gLen
If Slovo(gX, gY) = "." Then Exit For
gX = gX + dX(gDirect)
gY = gY + dY(gDirect)
Next
Else
For i = 1 To 1000
If gX > Grid.Width Or gY > Grid.Height Or gX < 1 Or gY < 1 Or Slovo.S(gX, gY) = "." Then Exit For
gX = gX + sx(gDirect)
gY = gY + dY(gDirect)
Next
End If

End Function

1. Can Function to change, so you can omit argunent glen when calling functions when we do not need. I am in this case wrote glen = 0

2. Can you make a function so that it returns a string array?
I would actually be:

Dim ii, jj
For gDirect = 1 To 8
ii = gY
jj = gY
For i = 1 To 1000
If ii > Grid.Width Or jj > Grid.Height Or ii < 1 Or jj < 1 Or Slovo.S(ii, jj) = "." Then Exit For
gX = gX + sx(gDirect)
gY = gY + dY(gDirect)
Next
Next

Then the function would have no arguments gDirect and Glen

Or to put Public GetMask (8), so do not do Function. but do Sub?

And finally, can function as we've written do simpler?
• June 20th, 2013, 07:46 AM
HanneSThEGreaT
Re: Omitting the argument in Function
Well have a look into Optional arguments :

http://msdn.microsoft.com/en-us/library/f25e2b6b.aspx
• June 20th, 2013, 12:53 PM
sinankrstarica
Re: Omitting the argument in Function
hahaha cool :)
I thank everyone and give up seeking help at the forum.
• June 20th, 2013, 01:51 PM
HanneSThEGreaT
Re: Omitting the argument in Function
What do you mean you found nothing there? :confused: i am really disappointed at your response :sad: really, really disappointed and majorly confused. flabbergasted.

Sometimes I wonder why I even bother to help!
• June 21st, 2013, 09:47 AM
DataMiser
Re: Omitting the argument in Function
Yeah that is rather odd.

The Optional arguments is the solution to the first question. The second question is just a matter of changing the return of the function

Code:

`Public MYFunction(SomeParam As String) as String()`