Jump to content

VB Tie System?

Arcapse

Can someone show me how, on Visual Basic, to code a 'tie system'? I'm working on a program for a competition to determine the winner. It selects the winner by a Find Maximum algorithm using a 1-D array. I'm a fairly novice user of VB.

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

Can someone show me how, on Visual Basic, to code a 'tie system'? I'm working on a program for a competition to determine the winner. It selects the winner by a Find Maximum algorithm using a 1-D array. I'm a fairly novice user of VB.

Use your logic. If Int1 == Int2 Then WinnerText = "Draw" or you can loop throught it and check it, You shouldn't be learning VB, I would recommend Java

Link to comment
Share on other sites

Link to post
Share on other sites

Use your logic. If Int1 == Int2 Then WinnerText = "Draw" or you can loop throught it and check it, You shouldn't be learning VB, I would recommend Java

I know, right now I have a boolean draw variable. But I don't know how to output multiple winners

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

I know, right now I have a boolean draw variable. But I don't know how to output multiple winners

Run a loop on the array and get all the winners to another arraylist, output the array in text using a loop

Link to comment
Share on other sites

Link to post
Share on other sites

Since you already have the winning score, just loop through all the participants and do something with every user that has that winning score.

Link to comment
Share on other sites

Link to post
Share on other sites

Use your logic. If Int1 == Int2 Then WinnerText = "Draw" or you can loop throught it and check it, You shouldn't be learning VB, I would recommend Java

1. VB's comparison operand is the same as the assignment - there are no double or triple equals signs.

2. Without knowing the OPs future aims or goals, study/work project undertaken decisions or past background, you would change his career path? That's extremely obnoxious & arrogant to be honest...

 

@Arcapse: In what format do your results from the array return in if there's (1) 1 winner (2) a tie with 2 winners (3) a tie with 3 winners please? It usually helps if you could post any code you have tried so far - so we can all give advice and tweak that (thereby helping you to learn & understand your code and design choices to improve), rather than writing something from scratch of our own thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

1. VB's comparison operand is the same as the assignment - there are no double or triple equals signs.

2. Without knowing the OPs future aims or goals, study/work project undertaken decisions or past background, you would change his career path? That's extremely obnoxious & arrogant to be honest...

 

@Arcapse: In what format do your results from the array return in if there's (1) 1 winner (2) a tie with 2 winners (3) a tie with 3 winners please? It usually helps if you could post any code you have tried so far - so we can all give advice and tweak that (thereby helping you to learn & understand your code and design choices to improve), rather than writing something from scratch of our own thanks.

1. Sorry, Just use to Java Coding double equals signs.

2. Did you read my second post? Anyways I'm just saying OP should also learn Java

Link to comment
Share on other sites

Link to post
Share on other sites

Can someone show me how, on Visual Basic, to code a 'tie system'? I'm working on a program for a competition to determine the winner. It selects the winner by a Find Maximum algorithm using a 1-D array. I'm a fairly novice user of VB.

Dim pointsArray[] As Integer =                                 Your 1D array of points dataDim points As Integer = 0Dim numberOfWinners As Integer = 0Dim highestPoint as Integer = 0For i As Integer = 0 to pointsArray.Length() -1   points = pointsArray(i)   If points > highestPoint Then                                New winner      highestPoint = points      numberOfWinners = 1   Else If points = highestPoint Then                          Another winner with same points      numberOfWinners += 1   Else                                                        Not a winner                                                               Do nothing   End IfNextMsgBox("There are " & numberOfWinners & " winner(s) with a score of " & highestPoint & "!")  

How about this? 

 Almost as cool as my temps  

Link to comment
Share on other sites

Link to post
Share on other sites

Dim pointsArray[] As Integer =                                 Your 1D array of points dataDim points As Integer = 0Dim numberOfWinners As Integer = 0Dim highestPoint as Integer = 0For i As Integer = 0 to pointsArray.Length() -1   points = pointsArray(i)   If points > highestPoint Then                                New winner      highestPoint = points      numberOfWinners = 1   Else If points = highestPoint Then                          Another winner with same points      numberOfWinners += 1   Else                                                        Not a winner                                                               Do nothing   End IfNextMsgBox("There are " & numberOfWinners & " winner(s) with a score of " & highestPoint & "!")  

How about this? 

 

Aye, I appreciate you taking the time to write that out for me, greatly appreciated :) But I need it to display the names of the two winners?

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

Aye, I appreciate you taking the time to write that out for me, greatly appreciated :) But I need it to display the names of the two winners?

Where are the names stored?

Another array? Or is the points array actually 2 dimensional?

(Or do you not know and are asking me?)

 Almost as cool as my temps  

Link to comment
Share on other sites

Link to post
Share on other sites

Right now, I have it set up in two different sub procedures (necessary) - the first is for finding the winner(s), I have the part working if it's just a single winner. The second sub program is for the display / output using a list box. I unfortunately don't have VB installed on this computer so I'll try manually typing it out or some shit.

draw = false

Sub 1:
For counter = 1 to 5
   If score(counter) > winnerscore Then                                
      winnerscore = score(counter)
      location = counter
   Else If score(counter) = winnerscore Then                          
      draw = true
   Else                                                                                                            
   End If
Next

Sub 2:

If draw = false Then
lstoutput.items.add("The winner was " & name(location) & " with a score of " & winnerscore)
Else if draw = true Then
lstoutput.items.add()
End If

I don't know how to store and establish these winners, and correctly output them. I need this program finished soon so help would be appreciated

 

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

I really need to get this figured out soon, help would be greatly appreciated

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

58 minutes ago, Arcapse said:

I really need to get this figured out soon, help would be greatly appreciated

What you have looks like it will work. You just need to finish the else block in sub 2 with another loop

draw = false

Sub 1:
For counter = 1 to 5
   If score(counter) > winnerscore Then
      winnerscore = score(counter)
      location = counter
   Else If score(counter) = winnerscore Then
      draw = true
   Else
   End If
Next

Sub 2:
If draw = false Then
    lstoutput.items.add("The winner was " & name(location) & " with a score of " & winnerscore)
Else if draw = true Then
    lstoutput.items.add("There was a tie. The winners with a score of " & winnerscore & " are:")
    For counter = 1 to 5
       If score(counter) = winnerscore Then
           lstoutput.items.add(name(counter))
       End If
    Next
End If

edit: Also, just a couple notes

If draw = False Then
' is equivalent to
If Not draw Then

' and

If draw = True Then
' is equivalent to
If draw Then

You don't have to do the equality check for the Boolean type. You also don't need an empty else block (like in Sub 1) if you aren't doing anything with it.

 

Link to comment
Share on other sites

Link to post
Share on other sites

34 minutes ago, madknight3 said:

What you have looks like it will work. You just need to finish the else block in sub 2 with another loop


draw = false

Sub 1:
For counter = 1 to 5
   If score(counter) > winnerscore Then
      winnerscore = score(counter)
      location = counter
   Else If score(counter) = winnerscore Then
      draw = true
   Else
   End If
Next

Sub 2:
If draw = false Then
    lstoutput.items.add("The winner was " & name(location) & " with a score of " & winnerscore)
Else if draw = true Then
    lstoutput.items.add("There was a tie. The winners with a score of " & winnerscore & " are:")
    For counter = 1 to 5
       If score(counter) = winnerscore Then
           lstoutput.items.add(name(counter))
       End If
    Next
End If

edit: Also, just a couple notes


If draw = False Then
' is equivalent to
If Not draw Then

' and

If draw = True Then
' is equivalent to
If draw Then

You don't have to do the equality check for the Boolean type. You also don't need an empty else block (like in Sub 1) if you aren't doing anything with it.

Cheers dude this helps a lot, much love <3

 

Cheers & Best Regards,

Arcapse

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×