Join 132,256 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,168 people online right now. Registration is fast and FREE... Join Now!
I am not too far on my code. I attached my gui and would be helpful to know that I set it up correctly and that I am on the right track.
I don't know what strategy to use to allow user to input several different GPA's under male and female and then figure the averages. Any help would be greatly appreciated. Thanks
vb
Public Class mainform
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xcombinationLabel.Click
End Sub
Private Sub xexitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xexitButton.Click Me.Close() End Sub
Private Sub xcalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xcalculateButton.Click Dim gpa As Decimal Dim InpGpa As String Const prompt As String = "Please enter GPA." Dim prompt2 As String = "Would you like to enter another GPA?" Dim isGPAok As Boolean
Do While InpGpa <> "Done" InpGpa = InputBox("Type a name or Done to quit.") If InpGpa <> "Done" Then Print(InpGpa) Loop
End Sub
Private Sub mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.xgenderListbox.Items.Add("Male") Me.xgenderListbox.Items.Add("Female") Me.xgenderListbox.SelectedIndex = 0
End Sub
Private Sub xgenderListbox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xgenderListbox.SelectedIndexChanged
End Sub
Private Sub xaverageGPAGroupBox_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xaverageGPAGroupBox.Enter
End Sub End Class
This post has been edited by Master Pimp P. Flow: 1 Apr, 2008 - 01:53 PM
If it were me, I'd likely have a textbox that holds the values with a Listbox that could then have values added to it from the text box....along with a clear and calculate button. Then have the calculate button loop through the items in the listbox, adding them and then calculating the average....something like this
CODE
Public Class Form2
Private Sub xbuttonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xbuttonAdd.Click
Ok, thank you for your reply no fear but i got it a little late. I am almost done but I still have a glich. Again the purpose is to allow the user to select a gender then a gpa and the program is to keep track of the average female gpa's, male gpa's and also combined gpa's. The problem is, my code returns 0 in all three of my labels. Any clue what i am doing wrong???? Thank You so much to whomever takes the time to reply.
vb
'Angela on April 1, 2008 'Purpose: Calculate Average GPA's Option Strict On Option Explicit On
Public Class mainform Private Sub xexitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xexitButton.Click Me.Close() End Sub
Private Sub xcalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xcalculateButton.Click
Dim i As Integer 'counter Dim imale As Integer 'male counter Dim ifemale As Integer 'female counter Dim accumulator As Decimal Dim accumulatorM As Decimal Dim accumulatorF As Decimal Dim combinedAvg As Decimal Dim maleavg As Decimal Dim femaleavg As Decimal
'average female gpa If Me.xgenderListbox.SelectedIndex = 0 Then i = i + 1 ifemale = ifemale + 1 accumulatorF = accumulatorF + femaleavg accumulator = accumulator + combinedAvg femaleavg = accumulatorF / ifemale combinedAvg = accumulator / i Me.xfemaleResultsLabel.Text = femaleavg.ToString Me.xcombinedResultsLabel.Text = combinedAvg.ToString
Else i = i + 1 imale = imale + 1 accumulatorM = accumulatorM + maleavg accumulator = accumulator + combinedAvg maleavg = accumulatorM / imale combinedAvg = accumulator / i Me.xmaleavgResultsLabel.Text = maleavg.ToString Me.xcombinedResultsLabel.Text = combinedAvg.ToString End If
End Sub
Private Sub mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.xgenderListbox.Items.Add("Male") Me.xgenderListbox.Items.Add("Female") Me.xgenderListbox.SelectedIndex = 0
For gpalistbox As Decimal = 2D To 4D Step 0.25D Me.xGpaListBox.Items.Add(gpalistbox.ToString) Next gpalistbox Me.xGpaListBox.SelectedIndex = 0
End Sub
End Class
EDIT: Please use code tags =>
This post has been edited by PsychoCoder: 2 Apr, 2008 - 08:05 PM
Could you post a screenshot of what your form looks like so I can see from where the inputs of data are coming?
could you tell me how to send you a screen shot?
I will try to explain it to you in the mean time, the more i work on this the worse it gets. I have a gender list box with male and female options. I also have a gpa list box with gpa's to choose from. In addition, I have a group box that will display my gpa results. One for Male one for female and one for the combination. The only two other buttons i have is a calculate and an exit button. I am also trying to post the GUI as this is due tomorrow and I don't have much time left to figure this out. Thanks for any help.
I guess what I'm trying to figure out is how you are separating the male and female gpas individually if you have a listbox with male/female (only 2) values and then another listbox with all the gpas of the males and females. That's why I was wanting to look at a screenshot so I could get a better idea of what we were working with. And I apologize, it looks like the copy and paste won't work in these forums. If you have windows/msn messenger you can contact me via jeremysydnor@hotmail.com and I'll see if we can't talk this through better in that manner rather than a forum.
I guess what I'm trying to figure out is how you are separating the male and female gpas individually if you have a listbox with male/female (only 2) values and then another listbox with all the gpas of the males and females. That's why I was wanting to look at a screenshot so I could get a better idea of what we were working with. And I apologize, it looks like the copy and paste won't work in these forums. If you have windows/msn messenger you can contact me via jeremysydnor@hotmail.com and I'll see if we can't talk this through better in that manner rather than a forum.
That's exactly what I have, 2 list boxes per my instructors wishes. I will have access to MSN a little later and will try to show u my interface then. Thank you for your time. (I have been working on this all day and now my code is totally wacked, looks worse than before)