Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-write an If Statement

Status
Not open for further replies.

mchoudhury

Programmer
Nov 26, 2004
71
GB
Hi Guys
How can i re-write this code so :

If TSP.Count - 1 = 1 Then
TelephoneCallPlanID = 1
End If

Dim cc As New ConnectionCharge(TelephoneCallPlanID)

if TSP.Count - 1 = x then
TelephoneCallPlanID = x

thanks
 
No this does not function.

If tsp is 3 - 1 will give 2 therefore i will also want the
TelephoneCallPlanID to be 2. the way your writing is if
TelephoneCallPlanID is 2 then TSP = what ever value - 1 = which will make TelephoneCallPlanID = 1

this will mess up my functions

Thanks anyway
 
found the answere:

TelephoneCallPlanID = i + 1

thanks
 
OK, now I'm really confused.

In your original post, you wanted to change the original if statement (which sets TelephoneCallPlanID to 1 if TSP.Count is 2) to a more generic solution where if TSP.Count - 1 = x then set TelephoneCallPlanID to x.

If x = TSP.Count - 1, then it's OK to set TelephoneCallPlanID to TSP.Count - 1 because that's the same as setting it to x. So you don't need the if statement at all.

And where did i come from?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top