Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27429

RoundDown Function

$
0
0
Code:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
    Public Function RoundDown(ByVal InputValue As Double) As Double
        Try
            Dim Deci As Long = InStr(1, CStr(InputValue), ".", CompareMethod.Text)
            If Deci > 0 Then
                Return (CDbl(Mid(CStr(InputValue), 1, Deci)))
            Else
                Return (InputValue)
            End If
        Catch
            MsgBox(Err.Description, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Round Down Error")
        End Try
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MessageBox.Show(RoundDown(5.71))
    End Sub
End Class

This does exactly what I want it to do and that is take a value and round it down. VB however shows me a warning:

Warning 1 Function 'RoundDown' doesn't return a value on all code paths. Are you missing a 'Return' statement? C:\Users\Monkey\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 17 5 WindowsApplication1

Not sure what I need to fix here if anything?

Viewing all articles
Browse latest Browse all 27429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>