When is a "" String equal to “ULXD4D=-G50”?

Weird behavior, when the string “ULXD4D=-G50” evaluates to ““. The block of code below is catching non-empty strings, like this one, which is eluding me:

Var part_num As String = “ULXD4D=-G50”

If part_num = “” Then
save_this_record = false
reject_reason = “Missing Part Number”
End If

It also get’s trapped in this alternate logic:

If part_num.Length < 1 Then
save_this_record = false
reject_reason = “Missing Part Number”
End If

In the debugger the variable is in fact “ULXD4D=-G50” - and it seems like it’s related to the presence of “=-” being part of the string(?) What am I missing here?

1 Like

It also fails on this string, “ULXD4D--G50”, which contains a “--” in the middle. This seems to be a pattern of failure, if the string contains a “=-” or “--” it evaluates to ““ and gets trapped.

Okay - it’s ME that’s the bug here (‘reject_reason’ lived outside a loop and wasn’t being reset).

How do I delete this post and pretend it never existed?

I would say leave the post, might help someone in the future.
Besides we all have rough days and talk to the rubber duck :grin:

3 Likes

We all do this from time to time, some more than others (me, I’m talking about me). Sometimes it helps us to know that it is a common plight of the developer.

3 Likes

I agree, it should be left. In the early days of the forum, you couldn’t edit posts at all. The intention is for this to be an archive of our experiences and knowledge, even when that isn’t flattering.

I think every single one of us has had a moment like this. Don’t think twice about it.

1 Like

Well I had totally forgotten about it - till you reminded me @Thom_McGrath ! :wink:
Appreciate all the nice comments - really, you guys are way cheaper than my therapist.

2 Likes