G
Guest
under one subroutine, i repeat the same if then statement on several variables.
basically i have the following structure:
if a1 < dob then (do something to a1)
if a2 < dob then (do something to a2)
....
if z4 < dob then (do something to z4)
what i would really like do is to condense this. these aren't the only
variables on the form, so i'm thinking that doing something like this won't
work:
Dim ctrl as Control
For each ctrl in Me.Controls
If ctrl < dob then (do something to ctrl)
Next ctrl
so i tried something like this:
Dim ctrl as Control
Dim i as Integer
For i = 1 to Controls.count
ctrl = Control(i). ???
Select Case ctrl
Case "a1", "a2", ... "z4"
If ctrl < dob then (do something to ctrl)
End Select
Next i
but clearly i'm not sure how to finish this or if i'm even on the right
track. if it sounds nonsensical, it's because i had a piece of script in
another language and i'm trying to translate it to vb (and my vb knowlege
isn't extensive).
thanks for any help!
basically i have the following structure:
if a1 < dob then (do something to a1)
if a2 < dob then (do something to a2)
....
if z4 < dob then (do something to z4)
what i would really like do is to condense this. these aren't the only
variables on the form, so i'm thinking that doing something like this won't
work:
Dim ctrl as Control
For each ctrl in Me.Controls
If ctrl < dob then (do something to ctrl)
Next ctrl
so i tried something like this:
Dim ctrl as Control
Dim i as Integer
For i = 1 to Controls.count
ctrl = Control(i). ???
Select Case ctrl
Case "a1", "a2", ... "z4"
If ctrl < dob then (do something to ctrl)
End Select
Next i
but clearly i'm not sure how to finish this or if i'm even on the right
track. if it sounds nonsensical, it's because i had a piece of script in
another language and i'm trying to translate it to vb (and my vb knowlege
isn't extensive).
thanks for any help!