Adding numbers from a user in an array

Reply

Join Date: Nov 2009
Posts: 1
Reputation: Kristan421 is an unknown quantity at this point 
Solved Threads: 0
Kristan421 Kristan421 is offline Offline
Newbie Poster

Adding numbers from a user in an array

 
0
  #1
Nov 19th, 2009
Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click

Dim numbers() As Integer = {myarray(x)}
Dim element As Integer
Dim total As Integer

For Each element In numbers
total = total + element
Next element

End Sub

This is the code I have for adding the numbers in an array, but I keep getting an error that pertains to the top line that says "Handles clause requires a WithEvents variable defined in the containing type or one of it's base types". The words "AddToolStripMenuItem" are underlined. How can I fix this?
This is an assignment for school and I really need help!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 258
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 40
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #2
Nov 19th, 2009
Your sub (code in that sub) is looking for an object -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ByVal sender As System.Object

When you declare an object, you have to show it. In this event you are coding under click event, refering to an object, probably a menu? (AddToolStripMenuItem)
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 530 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC