Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
For Loop to search and determain how many their are.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Phil1987, post: 127776, member: 31410"] Hello, I've just started getting into programming and I'm following a few tasks that have been set to learn and understand VB.NET. What i'm working on is a lottery program i've done all the number generation with an array. Now i'm trying to find out how to search that array for lets say less than or equal to 2 you've lost sadly its not working. Bellow is the code and every time even without anything in the Textbox it doesn't work and just displays you've won the £1,000,000. ballbox is an array that contains 5 numbers that are generated by another button. [Code] Private Sub BTN_Check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_Check.Click Dim i As Integer = 0 Dim Textbox1 As Integer = 0 Dim found As Integer = 0 i = Textbox1 For Each i In ballbox found += 1 Next If found <= 2 Then MsgBox("You have lost") ElseIf found = 3 Then MsgBox("You have won £10") ElseIf found = 4 Then MsgBox("You have won £450") ElseIf found = 5 Then MsgBox("You have won £5,000") ElseIf found = 6 Then MsgBox("You have won £1,000,000") End If [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
For Loop to search and determain how many their are.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom