|
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.
|
|
|
|
|
So VS is not working, or your app is not working ?
I repeat - there is no reason I can see for VS2008 to break your VB6 apps. You could try reinstalling whatever runtime it uses, you could google your error, etc.
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.
|
|
|
|
|
K I will try once reinstall VS 6.0 application.
|
|
|
|
|
Hi
I’m having some problems with a small vb.net application I wrote that inserts data into an Access database.
When I run the application as my self it works comepletely fine on the Windows 2003 server or my desktop XP box.
But when I run it under a local admin account on the Win 2003 server box it does not work and spits our the following error for each insert.
“The field is too small to accept the amount of data you attempted to add.”
The bit I’m having a difficult time understand is why it works under my logon and not a local server logon. There are no domain policies or restrictions in place over the server or local account function on the server. It seems to have something to do with jet/eledb.
It is not possibly for the data to be to large because;
1). I’ve got a string limit function which chops of anything larger that what the field should be and this is far less than the Access DB memo field that most columns are set at.
2). I’ve done a thorough analysis of the data and none if it exceeds the maximum column size.
My vb.net code it fairly typical……
Try
Dim ConnectString, SelectStatement As String
Dim Connect As OleDb.OleDbConnection = New OleDb.OleDbConnection
ConnectString = (My.Settings("Access_db_tests"))
SelectStatement = "INSERT INTO test_information (pk_test_information, department_name)"
Connect = New OleDb.OleDbConnection(ConnectString)
Dim Cmd As New OleDb.OleDbCommand(SelectStatement, Connect)
With Cmd.Parameters
.Add(New OleDb.OleDbParameter("@parameter_pk_test_information", pk_test_information))
.Add(New OleDb.OleDbParameter("@parameter_department_name", department_name))
End With
Connect.Open()
Cmd.ExecuteNonQuery()
Connect.Close()
Connect.Dispose()
Catch Ex As Exception
Dim details As String = "pk_test_information = " & pk_test_information & _
" insert_row_to_Access_database - error message >> " & Ex.Message
log_exception(details)
End Try
Does anyone have any ideas?
Any feedback would be much appreciated.
M
|
|
|
|
|
Martijn Groen wrote: Does anyone have any ideas?
This guy[^] knows almost everything; the first hit is it.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
The first hit it is NOT! I spent a fair bit of time Googling through this.
Reasoning behind this is
1). the application code runs 100% fine 100% of the time on one user account that has admin privileges but not another admin account that is local (no domain or other policies exist affecting this).
2). The data inputted is not greater than the max size of the Access database column, I have analyzed the data source (every last row and column of every row) and no data is larger than the limit (if the data for a column was too large then the code would not work fine with the exact same data as it did on the first user account)
3). There is a string limiter function that has been tested and it is not possible for the data that gets passed onto this insert code to exceed the limit because it will chop it off at the allowed limit at code level this is actually well below the limit of the columns in the access database.
I just regret this application has to have a sh*tty Access backend. I would have been done and dusted and had the bugs ironed out weeks ago had been on a proper database server backend.
M Access sometimes sux
|
|
|
|
|
Change your OleDbParameter creation code to explicitly define the fields being sent as paramters, such as field type and width. Do not rely on the OldDbParameter class to use its defaults like you're doing now.
|
|
|
|
|
I need a script to upload a file to an FTP server on a daily basis. The code can be in VB Script or Active-X or DOS commands in batch file. I can use window's scheduler to run that script daily. The FTP Server will have user name, pw to upload files.
Please help me in above regard.
Thanks in advance
Srinivas Mateti
|
|
|
|
|
|
Sir i Did nt get u.PLz can u b more clear
Thanks
Srinivas Mateti
|
|
|
|
|
Read the sticky posts on top (The first two posts).
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
You made me hover mouse on that link to see if you really searched that code.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
renatcoder ?
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.
|
|
|
|