Results 1 to 5 of 5

Thread: function problem ...

  1. #1

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    i don't really undertstand the basics about functions ... i tried making one for my program but i don't get the value i want ...

    average = ((((mp1 + mp2 + mp3 + mp4) * 2) + (midt + final)) / 10)

    Call test

    lblyraverage.Caption = average & " " & "[" & letter & "]"

    the letter value never comes up ... i just have the average
    ---by the way the line with "average" is one whole line ... n the variables r dimmed ... i just didn't copy those things to this thread

    my function looks like this:

    Public Function test()

    Dim letter As String

    Select Case average
    Case Is >= 97
    letter = "A+"
    Case Is >= 93
    letter = "A"
    Case Is >= 90
    letter = "A-"
    Case Is >= 87
    letter = "B+"
    Case Is >= 83
    letter = "B"
    Case Is >= 80
    letter = "B-"
    Case Is >= 77
    letter = "C+"
    Case Is >= 73
    letter = "C"
    Case Is >= 70
    letter = "C-"
    Case Is >= 65
    letter = "D"
    Case Is >= 60
    letter = "F"
    Case Is >= 0
    letter = "F-"
    End Select

    End Function

    how come i don't get the letter value?

  2. #2
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122
    Have you tried an ELSE statement with other resulting letter in you SELECT?

    Roger

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Nearly there, You just missed out one line just before End Function you need to put
    Code:
    test = letter
    this tells the function to return the value in letter.

    If it wasn't for this sentence I wouldn't have a signature at all.

  4. #4

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305

    nope

    no that didn't work ... i wonder y it won't give out the letter value ...

  5. #5
    Guest
    You wrote Select Case average Where did this "Avergae" come from? In order to use it in your Function, you must pass it through.

    Code:
    Public Function test(average)
    
        'Enter the rest of your code here...
        test = letter 'Return the letter
    
    End Function
    To call it, pass average through it. This should print out an -A
    Code:
    MyAverage = 92
    RetVal = text (MyAverage)
    Print RetVal

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