I am looking at another person's code. In fact I have to amend it!!
There is a line that I would not write and am wondering exactly what it means:
If ctl.Value & "" = "" Then
Is it the same as
If nz(ctl.Value,"") = "" then ?
If not, how does it differ?
Jim
On Monday, September 14, 2020 at 6:18:29 AM UTC-5, internet...@foobox.com wrote:
I am looking at another person's code. In fact I have to amend it!!
There is a line that I would not write and am wondering exactly what it means:
If ctl.Value & "" = "" Then
Is it the same as
If nz(ctl.Value,"") = "" then ?
If not, how does it differ?
Jim
ctl.Value & "" will return vbnullstring if ctl.Value is null because string concatenation does not error on null.
nz(ctl.Value, "") will return vbnullstring if ctl.Value is null because you explicitly called it out.
On Monday, 14 September 2020 13:10:01 UTC+1, Ron Paii wrote:
On Monday, September 14, 2020 at 6:18:29 AM UTC-5, internet...@foobox.com wrote:
I am looking at another person's code. In fact I have to amend it!!
There is a line that I would not write and am wondering exactly what it means:
If ctl.Value & "" = "" Then
Is it the same as
If nz(ctl.Value,"") = "" then ?
If not, how does it differ?
Jim
ctl.Value & "" will return vbnullstring if ctl.Value is null because string concatenation does not error on null.
nz(ctl.Value, "") will return vbnullstring if ctl.Value is null because you explicitly called it out.If I understand you correctly, they each result in the same value.
I will therefore stick with nz(), which to my mind is clearer. It does not rely on knowing the behaviour of string concatenation under these circumstances.
I hate 'tidying' up someone else's code when I am not sure that I am not altering the behaviour
Jim
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 51:00:48 |
Calls: | 6,649 |
Calls today: | 1 |
Files: | 12,200 |
Messages: | 5,330,302 |