Results 1 to 27 of 27

Thread: If statements drivin me crazy!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    If statements drivin me crazy!

    i need this program to display the 2 highest marks, but it only displays the highest mark twice, please help!

    Code:
    Option Strict On
    Option Explicit On
    
    Public Class Form1
        Dim highscore1, highscore2 As Double
        Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            Dim score As Double
            score = CDbl(txtInput.Text)
            If score > highscore1 Then
                highscore1 = score
    
                If score > highscore2 Then
                    highscore2 = score
                Else
                    If highscore1 - score < 0 Then
                        highscore1 = score
                    Else
                        If highscore2 - score < 0 Then
                            highscore2 = score
                        End If
                    End If
    
    
                End If
            End If
            
            txtInput.Text = "0"
        End Sub
    
        Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
            ListBox1.Items.Add("The two highscores are " & highscore1 & " and " & highscore2 & ".")
    
        End Sub
    
    
    End Class

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    You don't fix code just by reading it. You need to learn how to debug your code. Start by placing a breakpoint at the top of the btnAdd_Click method. You do that by either licking in the left-hand margin of the code window or else clicking the line and pressing F9. Now, when you run your project, execution will break at that line. You can now step through your code one line at a time by pressing F10. At every step you can test the values of all your variables and properties, evaluate expressions and many other things. What you need to do is check that all your variables contain the values you expect, then determine what you think will happen when you step. You then step and see if what you expected actually happened. As soon as that is not the case you have found a bug.

    Having said all that, you shouldn't even be writing code if you don't have a working algorithm. How can you write code that works if you don't even know exactly what it's supposed to do? It might be that you can debug your code and it will run through and do exactly what you think it should and still end up with the wrong answer. In that case you have a logic error, not a code bug.

    Do you actually have a series of steps that you can run through on paper and end up with the correct answer? If not then how can you possibly hope to get code that works? If you haven't confirmed your logic then you should be writing any code at all.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Re: If statements drivin me crazy!

    wow thanx for that, thanks for telling me nothin to help me, i pretty much got the code all worked out, and i have spent like an hour and a half on it, maybe i am not the best coder but im just starting out. all i asked for was some help, not a lecture.

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: If statements drivin me crazy!

    Quote Originally Posted by Jester-666
    wow thanx for that, thanks for telling me nothin to help me, i pretty much got the code all worked out, and i have spent like an hour and a half on it, maybe i am not the best coder but im just starting out. all i asked for was some help, not a lecture.
    And he's given you more than just the answer, he's given you a "coding problem solving method" which as you master it will become a more confident programmer, not to mention a quicker one too.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    Quote Originally Posted by Jester-666
    wow thanx for that, thanks for telling me nothin to help me, i pretty much got the code all worked out, and i have spent like an hour and a half on it, maybe i am not the best coder but im just starting out. all i asked for was some help, not a lecture.
    I could give you the answer but then what would you learn? I post here to help people become better developers, not to solve their problems for them. If you follow the advice I provided then you'll either find the issue or find that your logic is flawed. Either way, you're better off. You can sit there and wait for someone to hand you a fish if you want but I suggest that you put my fishing lesson to use and then you will improve your skills. That's the best help you can receive.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    following his lead, i won't give you the answer either, but i will ask you to consider this:

    how do you store the two highest scores? If you find a score higher than a previous high score, the old high score is automatically going to be the 2nd highest. Think about it and then apply it to your current code. As jmclhinley said, you need to go over your code logic. If your logic was correctly implemented then obviously it would work. It doesn't so therefore you've not implemented it correctly. I suggest also you step through it line by line as he suggested and watch the values assigned to highscore 1 and 2 and when they are assigned.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  7. #7
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: If statements drivin me crazy!

    This is a forum, not a school. Most schools are understaffed btw so there are enough venues for patronizing. Besides, such an algorithm is more than simply reassigning ex-highest scores. Every new value has to be tested on both highest marks so far. A beginner has to learn by example, sorry to disagree.
    Code:
            If score > highscore1 Then
    
                'there is a catch, try entering 3,5,7, and 1 - it won't work correctly
                'so uncomment the following and try to figure out why is it working
                'If highscore1 > highscore2 Then
                '    highscore2 = highscore1
                'End If
    
                'if score is bigger than highscore1, assign that bigger value to highscore1
                highscore1 = score
    
    
            Else 'the Else part gets executed only if score is not bigger than highscore1
    
                'so getting here means that score is not bigger than highscore1
                'but we still want to check if score is bigger than highscore2
    
                If score > highscore2 Then
                    'if it is, assign that bigger value to highscore2
                    highscore2 = score
    
                End If
    
            End If
    VB 2005, Win Xp Pro sp2

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    A beginner has to learn by example, sorry to disagree.
    And by what example does a beginner learn to use the debugger? I'm not saying you shouldn't provide a code solution, in this case or in others, but most people will simply copy and paste the code without ever really developing any sort of understanding of what it does and how they could have arrived at it themselves. The sooner a developer learns to use the debugger the better for them, so they can start solving their own problems. Every time you solve a problem for them you deny them a chance to learn how to solve the next one for themselves.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    This is a forum, not a school. Most schools are understaffed btw so there are enough venues for patronizing. Besides, such an algorithm is more than simply reassigning ex-highest scores. Every new value has to be tested on both highest marks so far. A beginner has to learn by example, sorry to disagree.
    Code:
            If score > highscore1 Then
    
                'there is a catch, try entering 3,5,7, and 1 - it won't work correctly
                'so uncomment the following and try to figure out why is it working
                'If highscore1 > highscore2 Then
                '    highscore2 = highscore1
                'End If
    
                'if score is bigger than highscore1, assign that bigger value to highscore1
                highscore1 = score
    
    
            Else 'the Else part gets executed only if score is not bigger than highscore1
    
                'so getting here means that score is not bigger than highscore1
                'but we still want to check if score is bigger than highscore2
    
                If score > highscore2 Then
                    'if it is, assign that bigger value to highscore2
                    highscore2 = score
    
                End If
    
            End If
    What happens if highscore2 was originally bigger than highscore1? I see nothing in the original code layout that says it can't be. But if it is always that highscore1 is bigger, ...
    Code:
    if score > highscore2 and score < highscore1 then
       highscore2 = score
    elseif score >= highscore1 then
       highscore2 = highscore1: highscore1 = score
    end if
    notice the >=. It is of course possible for the two highest scores to be exactly the same.
    Last edited by Lord Orwell; Oct 29th, 2008 at 11:49 PM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  10. #10

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Re: If statements drivin me crazy!

    Thanks for they help guys, and btw i dont just copy and paste the answer, it helps me learn what i was doing wrong. Thanx for the help.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    Half's code is implementing completely different logic to yours, so what you were doing wrong was not getting your logic straight before you tried to write code to implement that logic. VB code is not a universe unto itself. VB code is an implementation of an algorithm. If your algorithm is flawed then of course code that correctly implements that algorithm will not produce the correct result. If you don't even have an algorithm then getting the correct result will be pure luck.

    If I gave you three numbers and asked you to tell me what the two largest were I bet you could do it. That means that you must be able to follow a set of steps to come up with the result. That means that you must be able to describe those steps. That's the algorithm. That has nothing whatsoever to do with programming. Once you have the algorithm, then you can think about writing code to implement it.

    In summary, what you did wrong was going straight from the spec to the code with no design in between. It's a common beginner mistake and the sooner you learn to do the design part the sooner you will become a software developer. You'll realise that after the fact, but I can live with the lack of appreciation until then.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: If statements drivin me crazy!

    Quote Originally Posted by Lord Orwell
    Code:
    if score > highscore2 and score < highscore1 then
       highscore2 = score
    elseif score >= highscore1 then
       highscore2 = highscore1: highscore1 = score
    end if
    Yes no doubt it can be made more compact but Jester needs to get the hang of the simple IF first. The debugger is a more advanced topic than this and it can be very frustrating having to learn more to do less. I just thought stepping through is better for out of bounds exceptions at the beginner's level and an overkill here.
    VB 2005, Win Xp Pro sp2

  13. #13
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: If statements drivin me crazy!

    "That means that you must be able to follow a set of steps to come up with the result. That means that you must be able to describe those steps. That's the algorithm. That has nothing whatsoever to do with programming. Once you have the algorithm, then you can think about writing code to implement it." - GREAT ADVICE!

    my first computer class(long,long, ago...) the instructor(W. Don Marsh) made us write algorithm's that described simple things, like directions to our home.
    some people never got that the devil was in the details.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  14. #14
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    Yes no doubt it can be made more compact but Jester needs to get the hang of the simple IF first. The debugger is a more advanced topic than this and it can be very frustrating having to learn more to do less. I just thought stepping through is better for out of bounds exceptions at the beginner's level and an overkill here.
    it's not overkill. You step through line by line and you can hover over the variables and see exactly what the program is doing. That's what it's for. The original error is pretty obvious. It has to be greater than highscore1 to even get to highscore2's check. But by then you've already assigned it to highscore1. That's why his numbers always matched.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    Yes no doubt it can be made more compact but Jester needs to get the hang of the simple IF first. The debugger is a more advanced topic than this and it can be very frustrating having to learn more to do less. I just thought stepping through is better for out of bounds exceptions at the beginner's level and an overkill here.
    The debugger is for debugging, period. Like anything, it's best to learn how to use it in simple situations first, before applying it to more complex ones. People should look at situations like this as opportunities to improve their skills rather than just the need to solve the specific problem at hand. If you learn a problem solving methodology, rather than just a solution to one single problem, then you're less likely to get stumped by similar problems in the future. I didn't think this way when I started out either, but it will be to anyone's own benefit to come to this realisation sooner rather than later, and that's what I'm trying to help with.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  16. #16
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    Yes no doubt it can be made more compact but Jester needs to get the hang of the simple IF first. The debugger is a more advanced topic than this and it can be very frustrating having to learn more to do less. I just thought stepping through is better for out of bounds exceptions at the beginner's level and an overkill here.
    that's not all i did. His code always assigned the same number to both. Yours never will. Try this group:
    1, 6, 7, 5, 8, 3, 8

    If it is working properly, you should have 8 assigned to both and you don't.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  17. #17
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: If statements drivin me crazy!

    You didn't get the question correctly. Jester didn't want highest marks displaying twice. He needed the highest and the second below the highest values. Now, last time I checked 8 was not bigger than 8 (even with the debugger). Besides, what happened to "i won't give you the answer either"?
    VB 2005, Win Xp Pro sp2

  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: If statements drivin me crazy!

    Now, isn't this more fun than if I'd just posted a solution in the first reply?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #19
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: If statements drivin me crazy!

    I agree with jmc and in my opinion a programmer should know at least three things before using Visual Studio. First how to debug; second put option strict and explicit on; and lastly how to make use of the dynamic help.

    Now about the algorithm. Since no matter what kind of algorithm you may write, the code will make N(0) (N means the count of the values) instructions unless you make use of balanced binary tree. Since the instructions are going to be N(0) than why not add the values in to a list and than sort it, and then take the two highest (index 0 and 1) from the list. Even better idea, you can use sorted list. Isn’t this simple enough?

    On the other hand, if you will not have more than two values at a time than think what would be the possible highscore1 value. It will be equal to highscore2 or beiger. And the highscore2 value would be equal to highscor1 or less. So let say highscore1 and highscore2 are zeros and you push a new value. The value should be compared with the highscor1 first. If the value > highscore1 than highscor2 is set with the value highscore1 and than highscore1 is set with the new value. If the value is < highscore1 than it is compared with highscore2. If the value > highscore2 than set it with the new value.

  20. #20
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: If statements drivin me crazy!

    @jester -
    what are the "scores"? bowling league, fantasy nascar, golf, SAT, etc.????

    approx. how many scores will be looked at at one time?

    how are the scores entered? by the user one-at-a-time, a file, etc.???

    does the program need to remember scores across runs?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  21. #21
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    Quote Originally Posted by Half
    You didn't get the question correctly. Jester didn't want highest marks displaying twice. He needed the highest and the second below the highest values. Now, last time I checked 8 was not bigger than 8 (even with the debugger). Besides, what happened to "i won't give you the answer either"?
    ok then, if you have a class of students, and you want to show the two highest scores, what happens if two people ace the test? This is a simple example. Anywhere you see someone keeping score on ANYTHING, duplicate scores are allowed simply because they are from different people. And this also applies to video games. If i am playing pacman and i tie the top score, i at least want to be in position 2 on the score list.

    He never stated that he wanted no duplicate scores. That is you assuming something. And if he really is recording high scores, duplicates must be allowed.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  22. #22
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: If statements drivin me crazy!

    if we are going off the deep end...

    if two people are tied for high, then the next highest score is really third.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  23. #23
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: If statements drivin me crazy!

    Ah, but then you are assuming you have a class of students. 'Anywhere' and 'anything' is incorrect. You may have a patient with a score for some time period. Then you want to see the 2 highest scores he ever achieved before dying/getting healthy in terms of t°, glasgow coma scale, tumor suze, whatever.

    You made a different solution because you come from a different background (playing pacman and stuff) but this algorithm is by no means more or less appropriate than mine. It's just...different.
    VB 2005, Win Xp Pro sp2

  24. #24
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: If statements drivin me crazy!

    You guys do realize that you're both pushing valid points on stuff that Jester-666 hasn't even chimed in on. Perhaps all of you should just drop this for now until Jester-666 has provided more (if he provides any more) information here.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  25. #25

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Re: If statements drivin me crazy!

    I got this figured out a while ago, thanx for all the help, here is what i came up with.

    Code:
    Option Strict On
    Option Explicit On
    
    Public Class Form1
        Dim highscore1, highscore2 As Double
        Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            Dim score As Double
            score = CDbl(txtInput.Text)
    
            If score > highscore2 Then
                highscore2 = highscore1
            End If
    
            If score > highscore1 Then
                highscore1 = score
            Else
                If score > highscore2 Then
                    highscore2 = score
    
                End If
            End If
    
            txtInput.Text = "0"
        End Sub
    
        Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
            ListBox1.Items.Add("The two highscores are " & highscore1 & " and " & highscore2 & ".")
    
        End Sub
    
    
    End Class

  26. #26
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: If statements drivin me crazy!

    if it were me. i'd
    tryparse
    add to list
    at end
    sort list / reverse
    get list(0) and list(1)

    Code:
            Dim scoreL As New List(Of Double)
            Dim highscore1, highscore2, score As Double
            highscore1 = Double.MinValue
            highscore2 = Double.MinValue
            'test algorithm
            Dim somescores() As Double = New Double() {1, 15, 6, 32, 31, 4, 78, 3, 78, 80, 9, 10, 33, 79, 81}
            For Each s As Double In somescores
                Select Case s
                    Case Is >= highscore1
                        highscore2 = highscore1
                        highscore1 = s
                    Case Is > highscore2
                        highscore2 = s
                End Select
                Debug.WriteLine(highscore1.ToString() & " " & highscore2.ToString())
                scoreL.Add(s)
            Next
            'end test
            'If Not Double.TryParse(TextBox3.Text, score) Then
            '    'the textbox did not contain a Number
            '    Stop
            'End If
            'Select Case score
            '    Case Is >= highscore1
            '        highscore2 = highscore1
            '        highscore1 = score
            '    Case Is > highscore2
            '        highscore2 = score
            'End Select
            ''or
            ''scoreL.Add(score)
            ''scoreL.Sort() : scoreL.Reverse()
            '''highscore1 = scoreL(0) : highscore2 = scoreL(1) <<<<<<<<<<
            'If highscore1 <> Double.MinValue Then TextBox1.Text = highscore1.ToString
            'If highscore2 <> Double.MinValue Then TextBox2.Text = highscore2.ToString
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  27. #27
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: If statements drivin me crazy!

    Quote Originally Posted by Jester-666
    I got this figured out a while ago, thanx for all the help, here is what i came up with.

    Code:
    Option Strict On
    Option Explicit On
    
    Public Class Form1
        Dim highscore1, highscore2 As Double
        Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            Dim score As Double
            score = CDbl(txtInput.Text)
    
            If score > highscore2 Then
                highscore2 = highscore1
            End If
            If score > highscore1 Then
                highscore1 = score
            Else
                If score > highscore2 Then
                    highscore2 = score
    
                End If
           end if
            txtInput.Text = "0"
        End Sub
    
        Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
            ListBox1.Items.Add("The two highscores are " & highscore1 & " and " & highscore2 & ".")
    
        End Sub
    
    
    End Class
    i can't image a situation where this is what you intended. Perhaps if you explained it better?
    It looks to me that the way you wrote it, if score is greater than score 2 but NOT bigger than score 1, your code will copy score1 into score2 (red code) and then overwrite the value you just placed in score2 with the value in score (green code). That is unnecessary code.
    If this is what you intended however, please mark the thread as resolved.
    Last edited by Lord Orwell; Nov 1st, 2008 at 10:24 PM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width