|
I use Sql Reporting Services to create the report for an application.The reports are loaded in a web page using the ReportViewer.
My need is to be able to set in advance the Number of copies for a specific report.
I dont want to rely on the user to change the number of copies every time the report is produced, so i want the print dialog box of the Report Viewer ActiveX control to display Number of Copies = 4
|
|
|
|
|
Ok here is the whole code and the problem is right down the bottom with the myDice which I have underlined. Ok I deleted most of the code apart from where the error is
Error.... The name 'myDice' does not exist in the current context
Everything else works fine just not this part!
public int AddUpDice(int DieNumber, int[] Dice)
{
int Sum = 0;
for (int i = 0; i < 5; i++)
{
if (myDice[i].RollNumber == DieNumber)
{
Sum += DieNumber;
}
}
return Sum;
}
}
}
|
|
|
|
|
Rather than dumping the entire code you need to provide the exact error messages produced by the compiler.
[edit]
A quick run of the IDE shows that myDice is declared in the Form1 class and you are trying to access it from the CalculateScore class. However this is not possible without qualifying the name. As I said in answer to a number of your other messages, you should spend some time studying the basics of C#.
[/edit]
|
|
|
|
|
I did state the actual error minus the line number and col number that the compiler mentioned
|
|
|
|
|
Yes I spotted that after I checked the code, and explained what the error was.
|
|
|
|
|
It's in a different class...
CalculateScore is a class within Form1 class - it can't access Form1 objects!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hi,
I am reading inbox sms messages from gsm mobile
some messages are being received by following format. Please let me know, how may I convert this into text / string to read easily?
050003B60201AE65F6F8DD2E83E86F50D5FC769743206919CECE83EE693A1A146BCD40F437685E17CFC7F2B4B80CA2A3CBA079596E4F8FCBA0B719549583C6E8777A5C063DA5207919CECE83EE693A1A749A56852750DA0CCABFEBA07B7A8E06D1DFA0795D3C1FCBD3E23288FE0685D96CD0DB0CA2A3CBED9022D6AA52EBEEF21C040049E72E506C450DE35F
Thank you
(Riaz)
|
|
|
|
|
I do not know the structure of SMS messages, but I'm sure Google can find it for you. However, the above looks like hexadecimal so you just need to convert it to normal bytes.
|
|
|
|
|
I wonder what "normal bytes" are, they all look the same to me...
|
|
|
|
|
I changed it from "characters" as that seemed wrong; how would you describe it?
|
|
|
|
|
I'd say it looks like some kind of encoding; half of the hex values shown are above 0x80, so it sure isn't just ASCII characters. Our friend Google would know, as you said.
|
|
|
|
|
I meant rather "convert to ???". I know it's just a HEX representation of some message, and I also know that SMS messages contain lots of odd bits of information.
|
|
|
|
|
Hi can anyone tell me why the myDice which is the underlined part is giving me thie following error please.
name 'myDice' does not exist in the current context
I have up the top of the coding the following so not sure why it is not picking up this particular myDice.
int[] Dice = new int[] { 0, 0, 0, 0, 0, };
int[] myDice = new int[] { 0, 0, 0, 0, 0 };
public int AddUpDice( int DieNumber, int[] Dice )
{
int Sum = 0;
for (int i = 0; i < 5; i++)
{
if (myDice[i].RollNumber == DieNumber)
{
Sum += DieNumber;
}
}
return Sum;
}
|
|
|
|
|
|
how many people will downvote me...i understand this may not be the issue..
|
|
|
|
|
|
The reason why i post this solution is, once my code was not latest and i am trying to get the variable value and it's not accessible. so when i clean the solution and rebuild, it was working fine.
anyway thanks for downvote me... this will make my answer more perfect.
|
|
|
|
|
I didn't downvote you. I just posted the message saying you were WAY off.
Cleaning the solution and rebuilding works for cases where you make a change in the code, but for some reason the built version isn't running the updated code.
His problem simply dealt with variable scope and the curse of using "global" variables.
|
|
|
|
|
Where exactly is myDice defined?
int doesn't have a member RollNumber , so even if there wasn't a scope issue you'd get a compiler error (Or there's some hidden extension method?).
Another thing, there's a redundant parameter int[] Dice or is this a typo and you've intended to use myDice ?
2A
modified 18-Jun-12 4:07am.
|
|
|
|
|
If it isn't finding it there are a couple of reasons:
1) It is not declared in an appropriate scope
2) It is is declared as non static and you are referencing it from a static method.
You method declaration is not static , so it must be the first option.
Try something: place a private modifier in front of the myDice declaration:
private int[] myDice = new int[] { 0, 0, 0, 0, 0 };
If the compiler complains, then the declaration is within a method of some form, and will go out of scope at the closing close curly bracket. Objects outside the method cannot access variables declared within it.
It is generally a good idea to explicitly specify the access modifier for all variables: it makes it much clearer when you read the code.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Ok have now posted the whole code page in which this error is in which is right down the bottom of all the code.
|
|
|
|
|
Don't open a new question for that - edit your existing one!
As it happens, I have told you what the problem is with your code dump.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Given that you are working from this article[^] you should be able to resolve all these issues by looking at the code on that page. However, it also appears that you are new to programming (or maybe just C#), so you would be well advised to get hold of a good book and work through it to get your understanding of the basics to the right level. If you cannot find a book easily then .NET Book Zero[^] contains a great introductory tutorial.
|
|
|
|
|
Ah that's the problem it is not all there apparently as Teacher says its a really bad job done even he is having problems too.
|
|
|
|
|
Member 8336848 wrote: Teacher says its a really bad job done even he is having problems too.
Find a better teacher.
|
|
|
|