-
June 20th, 2013, 04:10 AM
#1
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
GetMask = ""
If gLen > 0 Then
For i = 1 To gLen
If Slovo(gX, gY) = "." Then Exit For
GetMask = GetMask & Slovo.S(gX, gY)
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
GetMask = GetMask & Slovo.S(gX, gY)
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
GetMask(gDirect) = ""
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
GetMask(gDirect) = GetMask(gDirect) & Slovo.S(ii, jj)
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
#2
Re: Omitting the argument in Function
-
June 20th, 2013, 12:53 PM
#3
Re: Omitting the argument in Function
hahaha cool
Nothing I have not found there, from what I asked.
I thank everyone and give up seeking help at the forum.
-
June 20th, 2013, 01:51 PM
#4
Re: Omitting the argument in Function
What do you mean you found nothing there? 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
#5
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()
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|