|
-
Oct 20th, 2011, 09:15 AM
#1
Thread Starter
New Member
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
-
Oct 20th, 2011, 09:34 AM
#2
Hyperactive Member
Re: I am stumped
hmm, overloading operator..
can you show whole code?
-
Oct 20th, 2011, 10:32 AM
#3
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
-
Oct 20th, 2011, 10:42 AM
#4
Thread Starter
New Member
Re: I am stumped
Ok,, I changed things up a bit, and here is what I have so far...
vb.net Code:
Private Sub btnCreate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreate.Click
'Declarations
Dim decSales() As Decimal = {"2400", "1500", "1600", "2790", "1000", "6300", "1300", "2700"}
Dim decBonus() As Decimal
Dim decInterestRate As Decimal
Dim decTotalBonusPaid As Decimal
Dim intBonusS As Integer = 0
'calculate the appropriate subscript
Decimal.TryParse(txtReport.Text, decBonus)
'calculate bonus
For intBonusS As Integer = 0 To 7 Step 1
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
-
Oct 20th, 2011, 10:47 AM
#5
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.
-
Oct 20th, 2011, 10:53 AM
#6
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
-
Oct 20th, 2011, 11:34 AM
#7
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|