I have a string that has FTP permissions – “LRSDCWAN” Is there a more efficiant way of checking the relevent CheckBox if the string contains the relevant character?
If reader.Item("home_perm").Contains("L") Then
CBoxList.Checked = True
End If
If reader.Item("home_perm").Contains("R") Then
CBoxRead.Checked = True
End If
If reader.Item("home_perm").Contains("S") Then
CBoxSubDir.Checked = True
End If
If reader.Item("home_perm").Contains("D") Then
CBoxDelete.Checked = True
End If
If reader.Item("home_perm").Contains("C") Then
CBoxCreate.Checked = True
End If
If reader.Item("home_perm").Contains("W") Then
CBoxWrite.Checked = True
End If
If reader.Item("home_perm").Contains("A") Then
CBoxAppend.Checked = True
End If
If reader.Item("home_perm").Contains("N") Then
CBoxRename.Checked = True
End If
Thanks.
While it doesn’t get rid of your .Contains() problem, you can simplify the logic quite a bit.
If you notice, you are using:
You can simplify this by just saying
You can do this for all of your checkboxes. It doesn’t solve the needing to call contains, but it eliminates 2/3 of your lines of code.