943,097 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 42
  • VB.NET RSS
Jul 31st, 2010
0

Need minor help on a program

Expand Post »
So in my class we are working with Arrays this week. We have to create a driver license exam program. It has to use multiple forms. First form the user inputs the answers then once he clicks the score button a new form pop's up stating the correct answers and how many he got correct. Now I created the program but have come across 2 problems.

FIRST:
VB.NET Syntax (Toggle Plain Text)
  1. Private strCorrect As String=("B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A")
I get a error at the fist comma after "B" it wants me to replace the comma with a ) but then that would make the array not work.

SECOND:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub btnScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScore.Click
  2. Dim Secound As New frmanswers
  3.  
  4. frmanswers.Show()
  5.  
  6. Dim intcount As Integer
  7.  
  8. strUser(0) = cbo1.SelectedItem
  9. strUser(1) = cbo2.SelectedItem
  10. strUser(2) = cbo3.SelectedItem
  11. strUser(3) = cbo4.SelectedItem
  12. strUser(4) = cbo5.SelectedItem
  13. strUser(5) = cbo6.SelectedItem
  14. strUser(6) = cbo7.SelectedItem
  15. strUser(7) = cbo8.SelectedItem
  16. strUser(8) = cbo9.SelectedItem
  17. strUser(9) = cbo10.SelectedItem
  18. strUser(10) = cbo11.SelectedItem
  19. strUser(11) = cbo12.SelectedItem
  20. strUser(12) = cbo13.SelectedItem
  21. strUser(13) = cbo14.SelectedItem
  22. strUser(14) = cbo15.SelectedItem
  23. strUser(15) = cbo16.SelectedItem
  24. strUser(16) = cbo17.SelectedItem
  25. strUser(17) = cbo18.SelectedItem
  26. strUser(18) = cbo19.SelectedItem
  27. strUser(19) = cbo20.SelectedItem
  28.  
  29. For x = 1 To 19
  30. If strCorrect(x) = strUser(x) Then
  31. intcount += 1
  32. End If
  33. Next
  34. End Sub

How do i get the answers from the user to transfer over to the other form where i have to display how many correct answers the user got correct?(hopefully the question does not confuse you)
I need the results of the loop to transfer over the the other form where the results is displayed onto a label. I will reply to the thread with the full code of the program that I have.
Last edited by wolfrain63; Jul 31st, 2010 at 3:33 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wolfrain63 is offline Offline
9 posts
since Jul 2010
Jul 31st, 2010
0
Re: Need minor help on a program
First form:
VB.NET Syntax (Toggle Plain Text)
  1. Public Class Main
  2.  
  3.  
  4. Private strCorrect As String=("B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A")
  5. Private strUser(19) As String
  6.  
  7. Private Sub btnScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScore.Click
  8. Dim Secound As New frmanswers
  9.  
  10. frmanswers.Show()
  11.  
  12. Dim intcount As Integer
  13.  
  14. strUser(0) = cbo1.SelectedItem
  15. strUser(1) = cbo2.SelectedItem
  16. strUser(2) = cbo3.SelectedItem
  17. strUser(3) = cbo4.SelectedItem
  18. strUser(4) = cbo5.SelectedItem
  19. strUser(5) = cbo6.SelectedItem
  20. strUser(6) = cbo7.SelectedItem
  21. strUser(7) = cbo8.SelectedItem
  22. strUser(8) = cbo9.SelectedItem
  23. strUser(9) = cbo10.SelectedItem
  24. strUser(10) = cbo11.SelectedItem
  25. strUser(11) = cbo12.SelectedItem
  26. strUser(12) = cbo13.SelectedItem
  27. strUser(13) = cbo14.SelectedItem
  28. strUser(14) = cbo15.SelectedItem
  29. strUser(15) = cbo16.SelectedItem
  30. strUser(16) = cbo17.SelectedItem
  31. strUser(17) = cbo18.SelectedItem
  32. strUser(18) = cbo19.SelectedItem
  33. strUser(19) = cbo20.SelectedItem
  34.  
  35. For x = 1 To 19
  36. If strCorrect(x) = strUser(x) Then
  37. intcount += 1
  38. End If
  39. Next
  40. End Sub
  41.  
  42. End Class

Second Form:
VB.NET Syntax (Toggle Plain Text)
  1. Public Class frmanswers
  2.  
  3. Private Sub Secound_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4. lblAnswers.Text=
  5.  
  6. End Sub
  7.  
  8.  
  9. End Class


End Class
Last edited by wolfrain63; Jul 31st, 2010 at 3:33 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wolfrain63 is offline Offline
9 posts
since Jul 2010
Jul 31st, 2010
0
Re: Need minor help on a program
OK so I figured out my first problem I have to use { instead of ) feel kinda dumb now. But still need help on my second problem.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wolfrain63 is offline Offline
9 posts
since Jul 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Student: Need help adding value to items in text box from list box in order to calc
Next Thread in VB.NET Forum Timeline: Advanced Printing in VB.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC