1

I have the following function in my Libre Office macro:

Function izracunajHash(geslo As String, zacetni_hash As Integer)
    If zacetni_hash = 1 Then
        izracunajHash = 5
    Else
        izracunajHash = 1
    End If
End Function

I call it this way inside Sub Main

print izracunajHash("Geslo", 5)

And it gives me the error Argument not optional on the second line of code If zacetni_hash = 1 Then.

What is the problem here?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
primix
  • 355
  • 1
  • 8
  • 1
    icyfox, where is the insertion point (the blinking cursor) when you run the macro? Place it inside `sub main` if it is not and try again? – Siddharth Rout Jan 18 '20 at 17:52
  • Siddharth Rout, thank you so much. This solved the issue, I had the insertion point in my function. Moving it down to sub main solved it :) – primix Jan 18 '20 at 17:57
  • Unfortunately, in Libre Office, unlike in MS Office, it will let you execute the function directly... – Siddharth Rout Jan 18 '20 at 17:58
  • Since this is a less know fact, I would recommend posting it as an answer and then accepting that answer. – Siddharth Rout Jan 18 '20 at 18:03

0 Answers0