Use of If statement with multiple conditions

前端 未结 6 2072
挽巷
挽巷 2021-01-15 23:54

I have written the following code which is basically supposed colour some boxes accordingly. Whenever i run this code, it runs the first case i.e. even when some other case

6条回答
  •  情歌与酒
    2021-01-16 00:36

    In addition to the errors noted by the other answers posted here, it is important to note the construct used for testing your condition is If with ElseIf. By using this to test your condition, you will always execute the first ElseIf condition resolving to True and skip any later conditions which may be defined.

    This means you may end up with logical issues in formatting according to the appropriate conditions you intended to format.

    For this reason, I would recommend using the Case statement construct as provided by @mwolfe02 in the response above along with all similar formatting conditions within the same Case statement. This would prevent various formatting situations from occurring based on what conditions had been met in a particular ordering of data.

    Hope that helps.

提交回复
热议问题