[help] KDR Calculator

Posts 1–8 of 8 · Page 1 of 1
[help] KDR Calculator
ok i got it but for some reason i get this error and i dont know want it means ? any help ? ty

Code:
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Function FKDR(ByVal Kills As String, ByVal Deaths As String, ByVal KDR As String)
        Dim Result As Double
        If KDR = 0 Then
            Result = Kills / Deaths
        Else
            Result = KDR * Kills - Deaths
        End If
        If KDR < 1 Then
            Return Format(Result, "0.00")
        Else
            Return Format(Result, "0")
        End If
    End Function
You're putting a function in a sub.
I PMEd him something different. Consider this thread as Solved
Quote Originally Posted by flameswor10 View Post
I PMEd him something different. Consider this thread as Solved
Code:
Function KDR(ByVal Kills As Integer, ByVal Deaths As Integer)
        Dim KDR As Double = Kills / Deaths
        Return KDR.ToString("N2")
End Function
if Deaths is 0 it triggers a divide by 0 exception.
You've got a function in a sub, possibly dividing by zero.. and you're checking and multiplying strings |:

Will post corrected code when I get home
Why would someone use a KDR calculator if they had no deaths?
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us