I am having trouble figuring out how to get my function (lines 45-57) to work. Option Strict is supposed to be on. I am getting the error "Option Strict On disallows implicit conversions from 'Decimal' to 'String'." This is an intro problem so its going to be basic.

Option Strict On

Public Class SalesForm
    Const COMMISSION_RATE_DECIMAL As Decimal = 0.15D
    Const QUOTA_DECIMAL As Integer = 1000
    Const BASE_PAY_INTEGER As Integer = 250


    Private Sub PayToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PayToolStripMenuItem.Click
        Dim WeeklyPayDecimal As Decimal
        Dim SalesPersonNameString As String
        Dim TotalSalesAmount As Decimal
        Dim CommissionDecimal As Decimal
        Try
            GetInput(WeeklyPayDecimal, SalesPersonNameString)
        Catch ex As Exception

        End Try
    End Sub
    Private Sub GetInput(ByRef WeeklyPayDecimal As Decimal, ByRef SalesPersonNameString As String)
        With Me
            If .SalesPersonNameTextBox.Text <> "" Then
                SalesPersonNameString = .SalesPersonNameTextBox.Text ' gets the name from the form
                Try
                    WeeklyPayDecimal = Decimal.Parse(WeeklySalesTextBox.Text)

                    If WeeklyPayDecimal = 0 Then ' makes sure that a number is entered
                        WeeklyPayDecimal = Decimal.Parse(.WeeklySalesTextBox.Text)

                    End If

                Catch 'catches nonnumeric data that is entered
                    MessageBox.Show("Nonnumeric data Entered")
                    .WeeklySalesTextBox.Focus()

                End Try
            Else 'missing data
                MessageBox.Show("Please Enter the Salesperson's Name")
                SalesPersonNameTextBox.Focus()

            End If
        End With

    End Sub
    Private Function WeeklySales(ByVal PayDecimal As Decimal, ByRef CommissionDecimal As Decimal, ByRef WeeklySalesDecimal As Decimal, ByRef TotalSalesAmount As Decimal) As String

        If WeeklySalesDecimal >= 1000 Then

            Return (COMMISSION_RATE_DECIMAL * WeeklySalesDecimal) + BASE_PAY_INTEGER

        Else

            Return(BASE_PAY_INTEGER + 

        End If

    End Function
    Private Sub SummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryToolStripMenuItem.Click

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        'closes the program
        Me.Close()

    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click

        'clears the form and puts the focus on the Salesperson Name textbox
        WeeklySalesTextBox.Clear()

        With SalesPersonNameTextBox
            .Clear()
            .Focus()
        End With

    End Sub

    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        'allows the user to change the font sytle 
        With FontDialog1
            .Font = SalesPersonNameTextBox.Font
            .ShowDialog()

        End With
    End Sub

    Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click

    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click

        'displays the about message box
        Dim MessageString As String

        MessageString = "AAlbersHW5" & Environment.NewLine & Environment.NewLine & "Programmed by Andrew Albers"
        MessageBox.Show(MessageString, "About AAlbersHW5", MessageBoxButtons.OK, MessageBoxIcon.Information)

    End Sub
End Class

Recommended Answers

All 2 Replies

1. Why not change the function signature and make it to return DECIMAL.
or
2. Convert the value (after all your calculation) into string before returning.

Thanks for the tip!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.