I want to show message when some value is not meet criteria (boolean have false value.) such as; if password is not long enough and uppercase is lower than 2 characters
now have 5 condition :
- password must be longer than 10 character
- Uppercase at least 1
- lowercase at least 1
If not meet whatever conditions will show in msgbox
when value is false will show in msgbox
CodePudding user response:
You can simply use multiple If
to append message to string variable. At last, check if there is any content in string variable and show message box if there is content
strMessage = ""
If Not clength Then strMessage = strMessage & "- Please length must be equal or more than 10 characters " & vbNewLine
If Not cUp Then strMessage = strMessage & "- Upcase at least 2 characters" & vbNewLine
If Not cLow Then strMessage = strMessage & "- Lowercase at least 2 characters" & vbNewLine
If Not cNum Then strMessage = strMessage & "- Number at least 2 characters" & vbNewLine
If Not cSpe Then strMessage = strMessage & "- Special character at least 2 characters"
If Len(strMessage) > 0 Then MsgBox "Your password is weak, please revise as following:" & vbNewLine & strMessage