Results 1 to 7 of 7

Thread: I am stumped

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    I am stumped

    I am having problems fixing a number of problems, this is one that keeps showing up. I don't know what to do to fix it, I have tried to change from integers to numbers to strings to decimals. I am writing a string array, but I am beat at this point. I may mention, I am brand new to programming, and this is my first class.

    Thanks,

    Monty.


    Error 5 Overload resolution failed because no accessible '*' can be called with these arguments:
    'Public Shared Operator *(d1 As Decimal, d2 As Decimal) As Decimal': Value of type '1-dimensional array of String' cannot be converted to 'Decimal'. C:\Users\Monty\Documents\School\Design Logic and Prog CINS 113\Zak Labs\Mid-Term project.vb\Mid-Term project.vb\JM Sales.vb 25 24 Mid-Term project.vb

  2. #2
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    491

    Re: I am stumped

    hmm, overloading operator..
    can you show whole code?

  3. #3
    Fanatic Member BlindSniper's Avatar
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    865

    Re: I am stumped

    The error tells you exactly what is wrong. You are trying to multiply an array of strings with a Decimal. Tell use what you are trying to do and post some relevant code (And use code tags) then we will be able to help

    Useful CodeBank Entries of mine
    Expand Function
    Code Compiler
    Sudoku Solver
    HotKeyHandler Class

    Read this to get Effective help on VBForums
    Hitchhiker's Guide to Getting Help at VBF

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Angry Re: I am stumped

    Ok,, I changed things up a bit, and here is what I have so far...
    vb.net Code:
    1. Private Sub btnCreate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreate.Click
    2.  
    3.         'Declarations
    4.         Dim decSales() As Decimal = {"2400", "1500", "1600", "2790", "1000", "6300", "1300", "2700"}
    5.         Dim decBonus() As Decimal
    6.         Dim decInterestRate As Decimal
    7.         Dim decTotalBonusPaid As Decimal
    8.         Dim intBonusS As Integer = 0
    9.  
    10.         'calculate the appropriate subscript
    11.         Decimal.TryParse(txtReport.Text, decBonus)
    12.  
    13.         'calculate bonus
    14.  
    15.         For intBonusS As Integer = 0 To 7 Step 1
    16.             decBonus[0] = decInterestRate * decSales[0]
    Here are the errors...



    Error 2 Variable 'intBonusS' hides a variable in an enclosing block. C:\Users\Monty\Documents\School\Design Logic and Prog CINS 113\Zak Labs\Mid-Term project.vb\Mid-Term project.vb\JM Sales.vb 22 13 Mid-Term project.vb


    Error 1 Value of type '1-dimensional array of Decimal' cannot be converted to 'Decimal'. C:\Users\Monty\Documents\School\Design Logic and Prog CINS 113\Zak Labs\Mid-Term project.vb\Mid-Term project.vb\JM Sales.vb 17 42 Mid-Term project.vb


    Error 4 Identifier expected. C:\Users\Monty\Documents\School\Design Logic and Prog CINS 113\Zak Labs\Mid-Term project.vb\Mid-Term project.vb\JM Sales.vb 23 22 Mid-Term project.vb



    Error 3 Expression is not a method. C:\Users\Monty\Documents\School\Design Logic and Prog CINS 113\Zak Labs\Mid-Term project.vb\Mid-Term project.vb\JM Sales.vb 23 13 Mid-Term project.vb

  5. #5
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: I am stumped

    Arrays in VB.NET are indexed with (), not []. decSales appears to be an array of Strings converted to Decimal - not illegal, I suppose, but not good coding practice. Remove the quotes around the numbers.

  6. #6
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: I am stumped

    Code:
     Dim decSales() As Decimal = {"2400", "1500", "1600", "2790", "1000", "6300", "1300", "2700"}
    Bad practice implicitly converting strings to decimals. Turn option strict on. Use
    Code:
     Dim decSales() As Decimal = {2400, 1500, 1600, 2790, 1000, 6300, 1300, 2700}
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Re: I am stumped

    Thanks folks! That worked!!!

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