Else If doesn't work how it should

Got it. Might be worth putting into the documentation that use of AndAlso can solve it. For example, if you’re trying to do something with these Else If conditions…

  • Dictionary Key “test” = “value”
  • Else If Dictionary Key “test” = “value2”
  • Else (do things if the value is something else or doesn’t exist)

Then the way to handle it is…

If yourDict.ContainsKey(“test”) AndAlso yourDict(“test”).ToString = “value”
Else If yourDict.ContainsKey(“test”) AndAlso yourDict(“test”).ToString = “value2”
Else…

1 Like