Why does vba want me to use assignment for function / subtitle?

I am trying to create a simple log function in my Excel VBA project.

I want to pass the current procedure name and string

now the log function is as follows:

Public Sub log(procName As String, message As String)
   dolog (procName & ": " & message)
End Sub

I try to call it this way:

Dim C_PROC_NAME As String
C_PROC_NAME = "autoSave"
log(C_PROC_NAME, "test")

This does not work, it seems to me that I am doing it like this:

test = log(C_PROC_NAME, "test")

And initializing C_PROC_NAME like this DOES NOT work:

DIM C_PROC_NAME As String = "autoSave"
+5
source share
1 answer

If you want to call sub with parens, you need to put the keyword Callin front:

Dim C_PROC_NAME As String
C_PROC_NAME = "autoSave"
Call log(C_PROC_NAME, "test")

Or you can call it without partners:

Dim C_PROC_NAME As String
C_PROC_NAME = "autoSave"
log C_PROC_NAME, "test"
+5
source

All Articles