943,882 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 803
  • VB.NET RSS
Dec 28th, 2008
0

vb dot net help

Expand Post »
i am using vb dot net. i want to store multiple values in a variable and then check whether any of the values held in the variable match what the user inputs. Please help i can not code it , i tried but failed.

This is not homework just a practice task so that i am able to code in vb dot net

could you please elaborate on answers as i do not how i would use arrays in this way thanks

i couldn't do it with arrays so tried with if statements and variable si know it doesn't work but just did it, to show you guys that i tried .

here is my code:

[ code] If voter number = voternumcheck Then
MsgBox("Please choose how you will like your voting to take place by clicking the appropriate button")
btnvotes.Enabled = True
btnpercentage.Enabled = True
Else code]
Thanks
Attached Files
File Type: zip My Code.rar.zip (34.0 KB, 37 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
asif786 is offline Offline
19 posts
since Dec 2008
Dec 28th, 2008
0

Re: vb dot net help

Go to google.com search on "array in VB.NET"
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Dec 29th, 2008
0

Re: vb dot net help

Here's a sample how to work with arrays
VB.NET Syntax (Toggle Plain Text)
  1. Private VoteArray() As Integer ' Array for items (integers in this case)
  2. Private Const VOTE_ARRY_SIZE As Integer = 3 ' Number of items in the array
  3. ' A help variable to hold "voted number"
  4. Private Voted As Integer
  5.  
  6. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  7. '
  8. ' Set array size. Notice: arrays are zero-based
  9. ReDim VoteArray(VOTE_ARRY_SIZE - 1)
  10. ' If you have continuous values, use a loop to fill the array
  11. VoteArray(0) = 2
  12. VoteArray(1) = 3
  13. VoteArray(2) = 4
  14.  
  15. End Sub
  16.  
  17. Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  18. '
  19. ' Notice: Voted value is now hard coded, you'll use textbox or something like that
  20. Voted = 2
  21. If [Array].IndexOf(VoteArray, Voted) >= 0 Then
  22. MessageBox.Show("Found", "Vote", MessageBoxButtons.OK, MessageBoxIcon.Information)
  23. Else
  24. MessageBox.Show("Not found", "Vote", MessageBoxButtons.OK, MessageBoxIcon.Information)
  25. End If
  26.  
  27. End Sub
Suggested reading: Array Class in MSDN
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008

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: Adding Notepad in VS2005
Next Thread in VB.NET Forum Timeline: Problem with ComboBox DataGridView Column





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


Follow us on Twitter


© 2011 DaniWeb® LLC