This is a code from a program in visual basic and I was wondering if there was a way to simplify it?
It takes the number of strings and says, if you equal this number then show this letter and this cover.
Is there a simpler way to do this so I don't have to repeat the code over and over again?
If UBound(Variables.Words) = "0" Then Round1.Letter6.Show() Round1.Cover6.Show() ElseIf UBound(Variables.Words) = "1" Then Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() ElseIf UBound(Variables.Words) = "2" Then Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() ElseIf UBound(Variables.Words) = "3" Then Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() ElseIf UBound(Variables.Words) = "4" Then Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() ElseIf UBound(Variables.Words) = "5" Then Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() ElseIf UBound(Variables.Words) = "6" Then Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() ElseIf UBound(Variables.Words) = "7" Then Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() Round1.Letter10.Show() Round1.Cover10.Show() ElseIf UBound(Variables.Words) = "8" Then Round1.Letter2.Show() Round1.Cover2.Show() Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() Round1.Letter10.Show() Round1.Cover10.Show() ElseIf UBound(Variables.Words) = "9" Then Round1.Letter2.Show() Round1.Cover2.Show() Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() Round1.Letter10.Show() Round1.Cover10.Show() Round1.Letter11.Show() Round1.Cover11.Show() ElseIf UBound(Variables.Words) = "10" Then Round1.Letter1.Show() Round1.Cover1.Show() Round1.Letter2.Show() Round1.Cover2.Show() Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() Round1.Letter10.Show() Round1.Cover10.Show() Round1.Letter11.Show() Round1.Cover11.Show() ElseIf UBound(Variables.Words) = "11" Then Round1.Letter1.Show() Round1.Cover1.Show() Round1.Letter2.Show() Round1.Cover2.Show() Round1.Letter3.Show() Round1.Cover3.Show() Round1.Letter4.Show() Round1.Cover4.Show() Round1.Letter5.Show() Round1.Cover5.Show() Round1.Letter6.Show() Round1.Cover6.Show() Round1.Letter7.Show() Round1.Cover7.Show() Round1.Letter8.Show() Round1.Cover8.Show() Round1.Letter9.Show() Round1.Cover9.Show() Round1.Letter10.Show() Round1.Cover10.Show() Round1.Letter11.Show() Round1.Cover11.Show() Round1.Letter12.Show() Round1.Cover12.Show() End If Any help is much appreciated!
Thanks, Dan.
EDIT ** I am not new to this but I only know basic functions. Sorry to be difficult, but could you show me full examples of what i would need to do.
Thanks, again.
switch...caseinstead ofif....else=how you can set a range comparison>=? because in the code its start checking from0to11and checks for every number. How you can set>=?