Wrox Programmer Forums
.NET 4 and Visual Studio 2010 General Discussions For discussing anything about .NET 4, WPF, WCF, the rest of the .NET 4 Framework, and Visual Studio 2010 that isn't about a specific Wrox book. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET 4 and Visual Studio 2010 General Discussions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 28th, 2013, 09:29 PM
Registered User
Join Date: Mar 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Program Hanging

I am working on a program that calculates class averages from each students scores. This button is supposed to create an inputbox to enter a new student name and add it to a list, clear the combobox drop down list selections and reset the student total variables so that my class total variables will accumulate correctly. I am also adding 1 to my numstudents every time the button is clicked (aka a new student is entered). The problem is when I click the button it brings up the Input Box and lets me enter a name and hit enter, but then it hangs and does not add the name to the list. I am not sure if it is the Input Box that is hanging or something about the way I am clearing the selected items. Any help would be greatly appreciated. I can email you the whole app if my code snippet is not enough to figure it out.

Private Sub btnNewStu_Click(sender As Object, e As System.EventArgs) Handles btnNewStu.Click
Dim strname1 As String
strname1 = InputBox("Student", "Name")

numstudents = numstudents + 1

boxForum1.SelectedItem = False
boxForum2.SelectedItem = False
boxForum3.SelectedItem = False
boxForum4.SelectedItem = False
boxForum5.SelectedItem = False
boxForum6.SelectedItem = False
boxForum7.SelectedItem = False
boxForum8.SelectedItem = False
boxAssign1.SelectedItem = False
boxAssign2.SelectedItem = False
boxAssign3.SelectedItem = False
boxAssign4.SelectedItem = False
boxAssign5.SelectedItem = False
boxAssign6.SelectedItem = False
boxAssign7.SelectedItem = False
boxAssign8.SelectedItem = False
boxFinProj.SelectedItem = False
Form3.boxProj.SelectedItem = False

Dim a As Integer = 0
While a < ForumScores.Length
ForumScores(a) = 0
End While

Dim b As Integer = 0
While b < AssignScores.Length
AssignScores(b) = 0
End While

StuForumTotal = 0
StuForumAverage = 0
StuAssignTotal = 0
StuAssignAverage = 0
StuTotal = 0
StuFinalScore = 0

lblStuTotPts.Text = String.Empty

End Sub

Old March 29th, 2013, 03:14 AM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts


Please have a look at the While loops with break point .. chances are it might be going infinitely

While a < ForumScores.Length
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips &amp; Tricks (http://www.vbadud.blogspot.com)
The Following 2 Users Say Thank You to Shasur For This Useful Post:
jminatel (March 29th, 2013), vbnetstudent (March 29th, 2013)
Old March 29th, 2013, 09:28 AM
Registered User
Join Date: Mar 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts

Thank you, Shasur. That is exactly what was holding it up. I was able to isolate it, by taking each separate piece of code out until it worked and didn't hang anymore. My two array loops were hanging it up.

I found this bit of code that sets all elements of an array to 0 or nothing and it solved my problem.


Call System.Array.Clear(info, info.GetLowerBound(0), info.Length)

Where "info" is the name of the array.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Queries hanging and never complete snufse SQL Language 0 March 24th, 2009 10:56 AM
Report Viewer is hanging up rachel_caleb13 Crystal Reports 0 July 11th, 2007 05:28 AM
VS2003 hanging gbrown VS.NET 2002/2003 3 October 9th, 2006 01:50 PM
Hanging process Gert SQL Server 2000 0 April 4th, 2005 04:08 AM
page hanging Adam H-W Javascript 6 October 28th, 2004 07:27 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.