|
I don't normally do student's homework, but seeing as you have attempted to solve the problem here is some pointers...
Remove the lines that declare the STATIC integer and make the PRIVATE member variables e.g.
Public Class Form1
Private intA As Integer
Private intB as Integer
Private intC as Integer
Private intD as Integer
Private intF as Integer
In the Form_Load Event handler, initiate the starting values e.g.
intA = 0
intB = 0
Now all you need is a Function to return the averages.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I figured it out Thank you both for steering me in the right direction. Not sure if its the most effcient way of making the program but it does what it's supposed to. Here is the final code...
'Adam Wike
'Computer Programming 1
'Grade Counter
'Created on March 28, 2010
'Last Modified on March 30, 2010
Public Class Form1
'Declared all variables
Private intA As Integer
Private intB As Integer
Private intC As Integer
Private intD As Integer
Private intF As Integer
Private intE As Integer
'Sets the variables to 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
intA = 0
intB = 0
intC = 0
intD = 0
intF = 0
End Sub
'Sets up the counter and calculates the percentage for each button
Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click
intA = intA + 1
lblGradea.Text = intA
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click
intB = intB + 1
lblGradeb.Text = intB
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click
intC = intC + 1
lblGradec.Text = intC
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnD.Click
intD = intD + 1
lblGraded.Text = intD
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
Private Sub btnF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnF.Click
intF = intF + 1
lblGradef.Text = intF
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
End Class
|
|
|
|
|
adamwike wrote: intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
The above should not be repeated in every button click event. Consider making in a sub-routine for example :
Private Sub CalcIntE()
intE = ((intA + intB + intC + intD) / (intA + intB + intC + intD + intF)) * 100
lblPassing.Text = Math.Round(intE, 2) & "%"
End Sub
Then replace the necessary code in each button click event with CalcIntE
for example
Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnA.Click
intA = intA + 1
lblGradea.Text = intA
CalcIntE
End Sub
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Your right, that is a lot less confusing and makes the program look less cluttered. Thanks!
|
|
|
|
|
adamwike wrote: that is a lot less confusing and makes the program look less cluttered
Not only that, but more importantly, it is more maintainable.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
i want to copy web page contents into a text file or excel using any script
how it will possible
please guide me
Regards
|
|
|
|
|
Use the HTTP classes to navigate tot he desired page and obtain its contents. then use the TextWriter to dump it to a filestream.
That is one method.
|
|
|
|
|
mates,
Is it possible to have to checkbox in single column of datagridview? If possible, how to do that? Thanks.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
|
I have installed an application that I have written on a windows 7 6g bit machine I am getting the follow error
Microsoft.Jet.OleDb.4.0 provider is not registered on the local machine.
any idea on how to fix it
by compiling code to x86 the program works in win 7 64 bit edition
modified on Sunday, March 28, 2010 9:49 PM
|
|
|
|
|
32 or 64 bit?
AFAIK there is no 64 bit version.
That may be an issue
try here for help
http://support.microsoft.com/kb/278604[^]
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
|
Sorry, didn't spot that in the question.
You may have to compile as 32 bit. (x86)
That's pushed my envelope of knowledge on it.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
how to I change the settings.
|
|
|
|
|
Since you cannot mix 32 and 64 bit code in the same process, you have to recompile your app not as Any COPU, but as x86. This forces your code to be compiled as a 32-bit app. There are no 64-bit Jet or Ole drivers, so you have no choice but to recompile your app.
|
|
|
|
|
how do I check that it is compiled as a 32 bit application?
|
|
|
|
|
For C#: Project menu -> <myprojectname> Properties. It's on the Build tab -> Platform Target.
For VB.NET: Project menu -> <myprojectname> Properties. It's on the Compile tab, click on the Advanced Compile Options button. It's the Target CPU option.
|
|
|
|
|
64 bit,
i have looked at the support link with no resolution, any other idea.
|
|
|
|
|
I would like to know if I need to dispose of anything in this code
Dim frmToRnd As System.Windows.Forms.Form = Me
Dim regionRects(radius * 2 + 2) As System.Drawing.Rectangle
Dim circle As New Bitmap(radius * 2, radius * 2)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(circle)
g.Clear(Color.White)
g.FillEllipse(Brushes.Black, 0, 0, circle.Width, circle.Height)
The rest of the code just uses what you see above. Do i use
Dispose.g
or do I need to dispose of regionRect and circle?
Thanks in advance for any help, time and patience.
rspercy60
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You should dispose objects that are IDisposable[^] because those objects' classes do implement this interface to provide the method Dispose to release unmanaged resources.
In your code you should dispose the Bitmap and the Graphics objects.
You should also read about the Using statement[^].
Eslam Afifi
|
|
|
|
|
Thank you very much Eslam. I knew somethings have to be disposed of, but
I didnt know what. Once again, Thank You.
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You're welcome.
Eslam Afifi
|
|
|
|
|
Hi Everybody!
I'm trying to capture all audio played through my computer's sound card to a WAV audio file. I've found a few examples like this one:
Sound Capture[^]
But they're all in VB6 and I'm struggling with the translation. Does anybody know of any examples in VB.NET that I could use to get an idea of how to accomplish this?
Thanks!
MrWolfy
|
|
|
|
|
Here is another one - I just used a search engine.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi!
Thanks for the link to the example, for it has answered some of my questions about working with WAV files in VB.NET. However, it does not seem to highlight how sound can be captured as it is played on a computer. Do you know of any examples that are capable of doing this?
MrWolfy
|
|
|
|