Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:00:13+00:00 2026-06-02T17:00:13+00:00

This function keeps giving me problem I cannot seem to find the right combination

  • 0

This function keeps giving me problem I cannot seem to find the right combination to get it working. I am trying to apply discount if certain amount is reached but I keep getting conversion error. What do I need to do so I define everything so it works?

Function coupon() As Decimal

        Dim decdiscount As Decimal
        Dim inta, intb, intc As Decimal

        inta = 20.0
        intb = 40.0
        intc = 60.0

        If lblSubtotal.Text > inta Then
            decdiscount = 0.05
        End If


        If lblSubtotal.Text > intb Then
            decdiscount = 0.1
        End If


        If lblSubtotal.Text > intc Then
            decdiscount = 0.2
        End If

        Return decdiscount
    End Function  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:00:16+00:00Added an answer on June 2, 2026 at 5:00 pm

    You really should enable Option Strict for your projects. It would help you avoid the conversion error at runtime by letting you know that you had an implicit conversion when you entered it. You could then use the Decimal.TryParse Method as BluesRockAddict and Andrew Kennan suggest.

    From above link:

    When you set Option Strict to On, Visual Basic checks that data types
    are specified for all programming elements. Data types can be
    specified explicitly, or specified by using local type inference.
    Specifying data types for all your programming elements is
    recommended, for the following reasons:

    • It enables IntelliSense support for your variables and parameters. This enables you to see their properties and other members as you
      type code.
    • It enables the compiler to perform type checking. Type checking helps you find statements that can fail at run time because of type
      conversion errors. It also identifies calls to methods on objects
      that do not support those methods.
    • It speeds up the execution of code. One reason for this is that if you do not specify a data type for a programming element, the Visual
      Basic compiler assigns it the Object type. Compiled code might have
      to convert back and forth between Object and other data types, which
      reduces performance.

    In your case it would flag the implicit conversions in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This function of mine keeps on failing an autograder, I am trying to figure
Another problem I've come across is this one. I'm trying to call this function
While trying to host the CLR, I keep getting this: error C2440: 'function' :
JSLint keeps giving me the following error whenever defining 2 functions: Problem at line
I'm trying to set the attribute of an element programmatically, but firebug keeps giving
Uploadify keeps giving me a HTTP error and its starting to get pretty annoying.
No matter what I try I keep getting an infinite loop with this function:
I keep getting 'warning: control reaches end of non-void function' with this code: -
This function calculates the number of bytes of the string str when encoded in
This function appears to be a way to access all sorts of system values.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.