08-14-2024, 03:38 PM
So here is one based on Ken's Calendar...
So to reduce lines, I would code it this way...
...but since I don't do speed tests, I can't really say if my example would run any faster. So what do you guys think? Is parsing a string faster than checking 12 conditions? If not, then we can just refer to this as a coding style.
Pete
- Just me parsing around.
Code: (Select All)
Do
Input "Input a number between 1 and 12"; n%
If n% > 0 And n% < 13 Then
If m = 1 Then month$ = "January"
If m = 2 Then month$ = "February"
If m = 3 Then month$ = "March"
If m = 4 Then month$ = "April"
If m = 5 Then month$ = "May"
If m = 6 Then month$ = "June"
If m = 7 Then month$ = "July"
If m = 8 Then month$ = "August"
If m = 9 Then month$ = "September"
If m = 10 Then month$ = "October"
If m = 11 Then month$ = "November"
If m = 12 Then month$ = "December"
Print month$
Else
End
End If
Loop
So to reduce lines, I would code it this way...
Code: (Select All)
month$ = "January February March April May June July August September October November December "
Do
Input "Input a number between 1 and 12"; n%
If n% > 0 And n% < 13 Then
Print LTrim$(Mid$(month$, (n% - 1) * 10, 10))
Else
End
End If
Loop
...but since I don't do speed tests, I can't really say if my example would run any faster. So what do you guys think? Is parsing a string faster than checking 12 conditions? If not, then we can just refer to this as a coding style.
Pete
- Just me parsing around.
Shoot first and shoot people who ask questions, later.