|
Dim iSum As Integer = 0
Dim dFAvg As Double = 0
Dim dDev As Double = 0
Dim dSqDev As Double = 0
i have these being declared before my subroutine
then this is my subroutine for my array using a for loop to load all values into teh list
but the part that dont know if i am dng correctly is my dDev= ((strArr(count) - dFavg) ^2) it keeps giving me the wrong answer
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
'***********************
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
'***********************
dDev = ((strArr(count) - dFAvg) ^ 2)
dSqDev += dDev
Next 'end for
|
|
|
|
|
PAguilar09 wrote: i have these being declared before my subroutine
This means your code will only work once.
PAguilar09 wrote: iSum += Convert.ToDouble(strArr(count))
iSum is an integer, why are you converting to double ?
PAguilar09 wrote: dFAvg = iSum / Convert.ToDouble(lblGrades.Text)
How does this calculate an average when it's done on each iteration ? Why not just use lstGrades.Items.Count instead of converting the string ?
Either way, it seems wrong to me. Each time around, the total so far gets divided by the total number of items ( not the number of items added so far ). Then you take this value, which is not an average of anything, and you subtract it from the last added value. Then you square that number. Then you add this to the cumulative total. I don't understand how that gives you any sort of meaningful result.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
So when you say that my code will only work once, then Do i need to declare in the subroutine my variables = 0??
I am converting the strArray(count) to Double because it is declared as a STRING when i create the variable. I dont know if it is the correct way to be doing it
on the last code you explained about, what it is doing is dividing the sum that has been passed to the Variable(iSum, a INTEGER)
then divide that by the total number of grades the user has entered, i convert it to double because since its a label.text it is a STRING not a numeric value.
Here is my total code maybe someone can tell me what it is i am dng wrong?? I have everything working fine BUT THE dDev = ((strArr(count)- dFAvg) ^2)
and then take that value being stored into dDev for each item from the listbox and find teh sum again.
Public Class GradeForm
Dim str As String
Dim strArr() As String
Dim count As Integer
Dim iSum As Integer = 0
Dim dFAvg As Double = 0
Dim dDev As Double = 0
Dim dSqDev As Double = 0
Dim dTotalDev As Double
Dim STD As Double
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'*************************************************************************************
'in this subroutine the User will click the save button to save grades to an array and
'then display the data required by the program.
'*************************************************************************************
Str = txtGrades.Text 'store string into variable
strArr = str.Split(" ") 'use split to seperate words by space
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
'***********************
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
'***********************
'********************THIS IS WHAT IS NOT WORKING CORRECTLY IT SEEMS THAT IT ISN'T GETTING EACH ELEMENT OR ITEM FROM TEH LIST BOX AND HAVE IT SUBRTRACTED BY THE AVG/MEAN, THEN RAISE IT OR MULTIPLY IT BY ITSELF (^2)***************************D
dDev = ((strArr(count) - dFAvg) ^ 2)
dSqDev += dDev
Next 'end for
lblAvg.Text = FormatNumber(dFAvg, 2) 'display average after storing calculation in variable, format to display only 2 decimal places
'this IS STILL NOT WORKING!!!!!*************************
lblSumDev.Text = FormatNumber(dDev, 2)
''''''''''''''''''''''this part is correct
STD = (lblSumDev.Text / (strArr.Length - 1))
Dim final As Double = Math.Round(Math.Sqrt(STD), 2)
lblStdDev.Text = final
End Sub
|
|
|
|
|
How to make multiline textbox to display the last element added or scroll to last?
|
|
|
|
|
you can scroll to the bottom. If you type the name of the textbox and hit the ., intellisense will let you see all the methods on the control, and you can also read MSDN to read up on the methods on a class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
use ScrollToEnd() or ScrollToCaret()
bless
|
|
|
|
|
I Am using VB6 it doesnt have scroll to end
|
|
|
|
|
Hi,
I am using using AVICAP32 for recording and saving Video.But when the form is minimized the Video is not saved also the Size of File for AVI files is very large when saved.What is the Problem and how it can be solved.
Is there any free dll which can be used in the Application.
|
|
|
|
|
kjsl2k9 wrote: also the Size of File for AVI files is very large when saved
avi files are not compressed, therefore they are large. I don't know what avicap32 is, but for the files to be smaller, you'd need to have some sort of codec installed, and to use it in your capture.
kjsl2k9 wrote: .But when the form is minimized the Video is not saved
This is somewhat meaningless. You don't even tell us what video you're capturing, I don't see how we can help based on this.
kjsl2k9 wrote: Is there any free dll which can be used in the Application.
Ultimately, you can do video capture using DirectX, and there are plenty of C# DX wrappers.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Everyone,
Can some one tell me how to create a VB.NET based application that could be used in a local server through which all the PCs are connected?
e.g. if I want to build a "Employee Record Management System" using VB and SQL Server 2005 database, and want users to work on this software installed on multiple PCs and simultaneously updating the database, then How to go ahaead with this?
I think, the software will be installed in all the PCS and SQL server Database will be on any separate PC which will act as server. I am not sure how to go ahead with this.
Any tutorials/links/refernces will be appriciated.
Thanks
RS.
|
|
|
|
|
Google Client Server development using VB.NET.
You really need to have some basic understanding of development concepts - if you have not done any sort of formal training, I recommend you get hold of a VB.NET book and learn the basics first!
|
|
|
|
|
I have done only windows based application with SQL sever 2005. Now I am moving to client-server based application.
|
|
|
|
|
Then buy a book on ASP.NET assuming that's how you write it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am currently allowing a user to enter in values into a text box. Then click a button to display the values and find the sum and mean of all the values entered. But i saw a problem when i was testing out the program.
When the user 1st runs the program it works perfecT! but if the user tries to re-enter new values and click the display button again, the sum and mean is added to the previous mean and sum so the values are way off!!! Here is my code I am not sure what I am forgetting to do? I know its something DEALING WITH MY FOR LOOP and COUNTER
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'*************************************************************************************
'in this subroutine the User will click the save button to save grades to an array and
'then display the data required by the program.
'*************************************************************************************
Str = txtGrades.Text 'store string into variable
strArr = str.Split(" ") 'use split to seperate words by space
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
Next 'end for
dFAvg = Convert.ToDouble(lblSum.Text) / Convert.ToDouble(lblGrades.Text) 'calculate average
lblAvg.Text = FormatNumber(dFAvg, 2) 'display average after storing calculation in variable, format to display only 2 decimal places
lblStdDev.Text = STD
End Sub
'this is the subroutine for my clear text box
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'********************************************************************8
'this subroutine will simply clear out the text box containing the user entered data
'as well as the lstbox displaying all the values entered
'and allow him/her to enter in new data
txtGrades.Text = ""
lblGrades.Text = ""
lblSum.Text = ""
lblAvg.Text = ""
lstGrades.Items.Clear()
txtGrades.Focus()
End Sub
|
|
|
|
|
I guess clearing iSum would help. Is iSum an integer or a double?
dFAvg = Convert.ToDouble(lblSum.Text) / Convert.ToDouble(lblGrades.Text) 'calculate average
Why do you use lblSum.text (and convert it back to double) when you have iSum? Same with lblGrades.Text
Tosch
|
|
|
|
|
|
It appears you aren't initialising iSum (or dFAvg).
In your clear routine, you need to include iSum = 0 and dFAvg = 0.
|
|
|
|
|
Thanks for the help I have another question. I am trying to figure out how to get each element of in the array and have it be subtracted by the mean value?
so for example If the user enters in the following: 10 10 10 10 10 ......... his sum is 50 and avg/mean is 10
so i am trying to write the code to do this following calculation but the syntax is incorrect what am i doing wrong?
Dim dSDev as Double
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
;********THIS IS WHAT I DNT KNOW WHAT IM AM DOING WRONG???*******************
dSDev = (strArr(count) - dFAvg)
'where dFAvg is simply the storing variable used to get the Mean/Avg value
*************************************************************************
Next 'end for
|
|
|
|
|
Hello to all,
I have generate an error while reading the text file.
The CLR has been unable to transition from COM context 0x5e0880 to COM context 0x5e09f0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Please give me the solution for this error.
If you can think then I Can.
|
|
|
|
|
You could post some code. You could make your app STA. You could google the error and see what you find.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Try
Dim OCAP1 As OpenFileDialog = New OpenFileDialog
Dim Filepath As String
OCAP1.Title = "Select Caption Text File"
OCAP1.Filter = "Text Files (*.txt)|*.txt"
OCAP1.FilterIndex = 2
OCAP1.RestoreDirectory = True
If OCAP1.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Sub
Filepath = OCAP1.FileName
Dim Reader1 As StreamReader = New StreamReader(Filepath)
While Reader1.Peek <> -1
ListBarcodecaption.Items.Add(Reader1.ReadLine())
End While
Reader1.Close()
count_barcaptions.Text = ListBarcodecaption.Items.Count.ToString() & " Items"
Button2_Click(Button2, e)
Catch ex As Exception
End Try
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: If OCAP1.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Sub
That's a bit nasty. why have more than one exit point ?
eg_Anubhava wrote: Button2_Click(Button2, e)
What's wrong with meaningful variable names ?
Which line throws the error ?
This is horrible convoluted code. What's wrong with File.ReadAllLines ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello to All
Recently I installed VS 2008 and before I m using VS 2005 and VS 6.0.
after installation of VS 2008 I m getting this error when I open VS 6.0 Application.
This message is appearing
"Please wait while windows configures My Application."
after that
"The Feature you are trying to use is on a network resource that is unavailable."
In Down this path also showing.
C:\DOCUME~1\Admin\LOCALS~1\Temp\ae6136\
If i press cancel This message was coming.
""An Insaillation package for the product My Application cannot be found. Try the installation again using valid copy of the installation package 'Setup.msi'"
How to solve this problem.
|
|
|
|
|
Well, VB6 has nothing to do with VB.NET. I assume that VS in these instances always means VB ? So, I don't see how VS could break VB6 apps
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
VS 6.0 is working but only starting case of form loading or application open or new form opening that time this error is coming how can i solve this error.
|
|
|
|