Results 1 to 2 of 2

Thread: Help me write this function for ASP

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Unhappy

    I have a website where I am summing up the total dollar value of registrants using a function that looks like the following: There is also another function that is formatted the same just with different values.



    Code:
    <%
    
    Dim intEarlyBird
    
    Function EarlyPrice()
    	Dim strRegArray(10)
    	Dim intLoop
    		Select Case lstReg1Type 'registration type from the first grouping
    			Case Individual
    				strRegArray(1) = 105 
    			Case Spouse
    				strRegArray(1) = 95 
    			Case ActivePulpitPastor
    				strRegArray(1) = 75 
    			Case SpecialStudentRate
    				strRegArray(1) = 75 
    			Case Else 
    				Response.Redirect "ErrorType.asp"
    							
    		End Select
    		
    		Select Case lstReg2Type 'registration type from the second grouping
    			Case Individual
    				strRegArray(2) = 105  
    			Case Spouse
    				strRegArray(2) = 95 
    			Case ActivePulpitPastor
    				strRegArray(2) = 75 
    			Case SpecialStudentRate
    				strRegArray(2) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg3Type 'registration type from the third grouping
    			Case Individual
    				strRegArray(3) = 105 
    			Case Spouse
    				strRegArray(3) = 95 
    			Case ActivePulpitPastor
    				strRegArray(3) = 75 
    			Case SpecialStudentRate
    				strRegArray(3) = 75 
    			Case Else
     				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg4Type 'registration type from the fourth grouping
    			Case Individual
    				strRegArray(4) = 105 
    			Case Spouse
    				strRegArray(4) = 95
    			Case ActivePulpitPastor
    				strRegArray(4) = 75 
    			Case SpecialStudentRate
    				strRegArray(4) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg5Type 'registration type from the fifth grouping
    			Case Individual
    				strRegArray(5) = 105 
    			Case Spouse
    				strRegArray(5) = 95
    			Case ActivePulpitPastor
    				strRegArray(5) = 75 
    			Case SpecialStudentRate
    				strRegArray(5) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg6Type 'registration type from the sixth grouping
    			Case Individual
    				strRegArray(6) = 105 
    			Case Spouse
    				strRegArray(6) = 95
    			Case ActivePulpitPastor
    				strRegArray(6) = 75 
    			Case SpecialStudentRate
    				strRegArray(6) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg7Type 'registration type from the seventh grouping
    			Case Individual
    				strRegArray(7) = 105 
    			Case Spouse
    				strRegArray(7) = 95
    			Case ActivePulpitPastor
    				strRegArray(7) = 75 
    			Case SpecialStudentRate
    				strRegArray(7) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg8Type 'registration type from the eigth grouping
    			Case Individual
    				strRegArray(8) = 105 
    			Case Spouse
    				strRegArray(8) = 95
    			Case ActivePulpitPastor
    				strRegArray(8) = 75 
    			Case SpecialStudentRate
    				strRegArray(8) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg9Type 'registration type from the ninth grouping
    			Case Individual
    				strRegArray(9) = 105 
    			Case Spouse
    				strRegArray(9) = 95
    			Case ActivePulpitPastor
    				strRegArray(9) = 75 
    			Case SpecialStudentRate
    				strRegArray(9) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg10Type 'registration type from the tenth grouping
    			Case Individual
    				strRegArray(10) = 105 
    			Case Spouse
    				strRegArray(10) = 95
    			Case ActivePulpitPastor
    				strRegArray(10) = 75 
    			Case SpecialStudentRate
    				strRegArray(10) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    '-- Sum up the total selections
    		
    		For intLoop = 1 to 10
    		
    		intEarlyBird = intEarlyBird + Cint(strRegArray(intLoop))
    		
    		Next
    		
    		
    		
    		
    End Function
    		
    %>
    I am then calling the function from another .asp page.

    But where I am lost is how to write code to determine which function to call based on the current date? The registration price changes after March 31,2001.

    Below is the code for the .asp page that calls the two and functions

    any ideas? Code please.


    Code:
    '--	Call the Date Functions
    
    		MyDate = Date	
    			If MyDate <= "03/31/01" Then 
    			EarlyPrice()
    			Else RegPrice()
    			
    		gDateEarlyPassed = EarlyPrice()
    		gDateRegularPassed = RegPrice()
    			
    		If gDateEarlyPassed = intEarlyBird Then
    			'continue
    		Else gDateRegularPassed = intRegBird
    			'continue
    		End If
    		
    '-- Add new record to the database

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    My suggestion would be to store the prices in a database and update it when the prices change.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width