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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

optimizing code

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi i have the day of the week as check boxes on a form, if the user enables teh check boxes they all days of weeks have values (but the user can change the values for each day) Its Either all weekdays have value or none of them. Below is what i wrote to set the price attributes and increment the days, Is there a more effecient way to accomplish what i have: (Thanks)

Code:
If Not IsNull(objRS("Sun")) Then

dblTempPrice = CDbl(objRS("Sun"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(objRS("RateStartDate")) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

varNewRateStartDate = objRS("RateEndDate")
varNewRateEndDate = DateAdd("d",1,varNewRateStartDate)
			
dblTempPrice = CDbl(objRS("Mon"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ xperson=""" & objRS("ExtraCharge2") & """/>")		
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
dblTempPrice = CDbl(objRS("Tue"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)

dblTempPrice = CDbl(objRS("Wed"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
dblTempPrice = CDbl(objRS("Thu"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
dblTempPrice = CDbl(objRS("Fri"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
dblTempPrice = CDbl(objRS("Sat"))
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

Else

rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(varNewRateEndDate)  & """ price=""" & FormatCurrency(dblTempPrice,2) & """/>")		

End If
 
sry here is the actual code:

Code:
If Not IsNull(objRS("Sun")) Then
dblTempPrice = CDbl(objRS("Sun"))
varNewRateEndDate = DateAdd("d",1,objRS("RateStartDate"))
			objRS("RateStartDate")
			
rateNode = rateNode & encodeXML("<rate start=""" &  objRS("RateStartDate") & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		

dblTempPrice = CDbl(objRS("Mon"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		

dblTempPrice = CDbl(objRS("Tue"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")

dblTempPrice = CDbl(objRS("Wed"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")

dblTempPrice = CDbl(objRS("Thu"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		

dblTempPrice = CDbl(objRS("Fri"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)
			
rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		

dblTempPrice = CDbl(objRS("Sat"))
varNewRateStartDate = varNewRateEndDate
varNewRateEndDate = DateAdd("d",1,varRateStartDate)

rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		
			
Else

rateNode = rateNode & encodeXML("<rate start=""" &  GDSdates(varNewRateStartDate) & """ stop=""" &  GDSdates(objRS("RateEndDate"))  & """ price=""" & FormatCurrency(dblTempPrice,2) & """ >")		

End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top