Question : VB.net code minimization

I'm trying to not duplicate a bunch of code and want to know if there is a way around this.

I have the following conditions

If A = "SomeValue" then
   If Date1 <= Date2 then
     Do a bunch of stuff
  end if
elseif A = "SomeOtherValue" then
   If Date1 >= Date2 then
     Do a bunch of stuff
  end if


The part I'm trying to not repeat is the data in the if statement after the date compares. There is about a 100 lines of code setting a bunch of local variables or dataset values. The 100 lines of code is the same for each date comparision. I don't want to put that in a function because there would be too many variables to pass in.

Is there any way to dynamically switch the Date comparison from >= to <= based on the value of A?

Probably not but I thought I would ask the gurus.

This isn't all of the code. I have about 6 conditions to check for value A

Answer : VB.net code minimization

For you 6 comparisons:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
If (A = "SomeValue" AndAlso Date1 <= Date2) OrElse
   (A = "SomeOtherValue" AndAlso Date1 >= Date2) OrElse
   (comparison1 AndAlso comparison2) OrElse
   (comparison3 AndAlso comparison4) OrElse
   (comparison5 AndAlso comparison6) OrElse
   (comparison7 AndAlso comparison8) OrElse Then

	Do a bunch of stuff
	
End If
Random Solutions  
 
programming4us programming4us