Results 1 to 4 of 4

Thread: Creating my own Function. Help please!

  1. #1

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

    Talking

    What is the correct way to code the sum of these variables?

    Dim intEarlyBird

    Function EarlyRegPrice()
    Dim intReg1, intReg2, intReg3

    Select Case strReglType 'registration type from the first grouping
    Case Individual
    intReg1 = 105
    Case Spouse
    intReg1 = 95
    Case ActivePulpitPastor
    intReg1 = 75
    Case SpecialStudentRate
    intReg1 = 75
    Case Else --
    Response.Redirect "ErrorType.asp"

    End Select

    Select Case strReg2Type 'registration type from the second grouping
    Case Individual
    intReg2 = 105
    Case Spouse
    intReg2 = 95
    Case ActivePulpitPastor
    intReg2 = 75
    Case SpecialStudentRate
    intReg2 = 75
    Case Else --
    Response.Redirect "ErrorType.asp"

    End Select

    Select Case strReg3Type 'registration type from the third grouping
    Case Individual
    intReg3 = 105
    Case Spouse
    intReg3 = 95
    Case ActivePulpitPastor
    intReg3 = 75
    Case SpecialStudentRate
    intReg3 = 75
    Case Else --
    Response.Redirect "ErrorType.asp"

    End Select


    intEarlyBird = sum(intReg1 - intReg16)

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'One Way
    
    Dim intEarlyBird
    
    Public Function EarlyRegPrice(one As Double, two As Double, three As Double) As Double
        intEarlyBird = (one + two + three)
         EarlyRegPrice = intEarlyBird
    End Function
    
    Public Sub getReg()
    
        Dim intReg1 As Double, intReg2 As Double, intReg3 As Double
        
        Select Case strReglType 'registration type from the first grouping
        Case Individual
        intReg1 = 105
        Case Spouse
        intReg1 = 95
        Case ActivePulpitPastor
        intReg1 = 75
        Case SpecialStudentRate
        intReg1 = 75
        'Case Else --
        'Response.Redirect "ErrorType.asp"
        
        End Select
        
        Select Case strReg2Type 'registration type from the second grouping
        Case Individual
        intReg2 = 105
        Case Spouse
        intReg2 = 95
        Case ActivePulpitPastor
        intReg2 = 75
        Case SpecialStudentRate
        intReg2 = 75
        'Case Else --
        'Response.Redirect "ErrorType.asp"
        
        End Select
        
        Select Case strReg3Type 'registration type from the third grouping
        Case Individual
        intReg3 = 105
        Case Spouse
        intReg3 = 95
        Case ActivePulpitPastor
        intReg3 = 75
        Case SpecialStudentRate
        intReg3 = 75
        'Case Else --
        'Response.Redirect "ErrorType.asp"
        
        End Select
        'some dummy info for testing
        
        strReglType = "Spouse"
        strReg2Type = "SpecialStudentRate"
        strReg3Type = "ActivePulpitPastor"
        
        MsgBox EarlyRegPrice(intReg1, intReg2, intReg3)
    End Sub
    
    
    Private Sub Command1_Click()
        getReg
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

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

    Talking

    Great Thanks but I am writing this in ASP. Will this syntax also work?

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    For ASP I do believe you need to use VBScript or JavaScript and I don't know enought about either to lend a hand. Check around for ASP Forums..there are a lot of them and I do believe some of the pjeople here could help as well.

    Sorry.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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