lately I found myself in conditions where a certain function could be used with or without value but during the compilation if I don't specify an empty string or a zero it gives me an error, is there a way to ignore the absence of value between the brackets?
exagonx wrote: ↑Jan 24, 2022 10:59
Hello guys, I have a question:
lately I found myself in conditions where a certain function could be used with or without value but during the compilation if I don't specify an empty string or a zero it gives me an error, is there a way to ignore the absence of value between the brackets?
Optional parameters. Just assign a default value to the parameter, like this:
' adding = -1 give a default value
sub x(byval value as integer = -1)
if value < 0 then print "no value" else Print "the value are: " & value
end sub
x(20) 'with value
x() 'with no value