| | |
how to loop this code?
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Dec 2008
Posts: 14
Reputation:
Solved Threads: 0
i want to loop this could because i do not have a fixed number of values:
thanks alot
vb Syntax (Toggle Plain Text)
Private VoteArray() As Integer ' Array for items (integers in this case) Private Const VOTE_ARRY_SIZE As Integer = 3 ' Number of items in the array ' A help variable to hold "voted number" Private Voted As Integer Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Set array size. Notice: arrays are zero-based ReDim VoteArray(VOTE_ARRY_SIZE - 1) ' If you have continuous values, use a loop to fill the array VoteArray(0) = 2 VoteArray(1) = 3 VoteArray(2) = 4 End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click ' Notice: Voted value is now hard coded, you'll use textbox or something like that Voted = 2 If [Array].IndexOf(VoteArray, Voted) >= 0 Then MessageBox.Show("Found", "Vote", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageBox.Show("Not found", "Vote", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub
Last edited by Ancient Dragon; Jan 5th, 2009 at 3:36 pm. Reason: correct code tags and removed manual line numbers
![]() |
Similar Threads
- Do/While Loop help (C++)
- How can I add a loop for this code (C++)
- Problem with while loop... probably common (C++)
- Doesn't check if username or email exits in database properly (ASP.NET)
- problem creating a for loop for an array (C++)
- loop problem (C++)
- Do while Loop to display a choosen month and the dates in it (ASP)
- Loop Issues (C)
Other Threads in the VB.NET Forum
- Previous Thread: Problem with simple ComboBox
- Next Thread: about outlook express
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic beginner browser button buttons center check code component connectionstring crystalreport cuesent data database databasesearch datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter folder forms ftp generatetags hardcopy html images input insert intel monitor net networking open output panel passingparameters peertopeervideostreaming picturebox picturebox1 port printing problem problemwithinstallation project reports" searchvb.net select serial settings shutdown sqlserver survey tcp temperature text textbox timespan toolbox transparency trim updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio.net visualstudio2008 web winforms wpf wrapingcode year






