Question[Help]ElseIf, EndIf. If[Closed]

Posts 1–15 of 16 · Page 1 of 2
[Help]ElseIf, EndIf. If[Closed]
I need help for the code highlighted in red.
So if a "combbox7.text = combbox8.text"
then
"combbox7.text = red and combbox8.text = red"

but

when they are different meaning when combbox7.text does not equal combbox8.text

return to original colour `black`
so combbox7.text = black
and combbox8.text = black.

but that doesnt work. the code to turn the text back to black.

Heres the code:
Code:
            If ComboBox7.Text = ComboBox8.Text Or ComboBox7.Text = ComboBox9.Text Or ComboBox8.Text = ComboBox9.Text Then
            MessageBox.Show("You have two or more of the same perk.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
            If ComboBox7.Text = ComboBox8.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox8.ForeColor = Color.Red
            ElseIf ComboBox7.Text = ComboBox9.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            ElseIf ComboBox8.Text = ComboBox9.Text Then
                ComboBox8.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            Else
                ComboBox7.ForeColor = Color.Black
                ComboBox8.ForeColor = Color.Black
                ComboBox9.ForeColor = Color.Black
            End If
        ElseIf ComboBox1.Text = ComboBox3.Text Or ComboBox1.Text = ComboBox6.Text Or ComboBox3.Text = ComboBox6.Text Then
            MessageBox.Show("You have two or more of the same weapon.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
        End If
Code:
       
     If ComboBox7.Text = ComboBox8.Text Or ComboBox7.Text = ComboBox9.Text Or ComboBox8.Text = ComboBox9.Text Then
            MessageBox.Show("You have two or more of the same perk.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
            If ComboBox7.Text = ComboBox8.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox8.ForeColor = Color.Red
            ElseIf ComboBox7.Text = ComboBox9.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            ElseIf ComboBox8.Text = ComboBox9.Text Then
                ComboBox8.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            Else
                ComboBox7.ForeColor = Color.Black //this will never happen
                ComboBox8.ForeColor = Color.Black //this will never happen
                ComboBox9.ForeColor = Color.Black //this will never happen
            End If
        ElseIf ComboBox1.Text = ComboBox3.Text Or ComboBox1.Text = ComboBox6.Text Or ComboBox3.Text = ComboBox6.Text Then
            MessageBox.Show("You have two or more of the same weapon.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
        End If
Those 3 in the else will never happen because:
Code:
//this is Treeham code so it will give you a ton of syntax errors if you try to compile it
If ComboBox7.Text = ComboBox8.Text Or ComboBox7.Text = ComboBox9.Text Or ComboBox8.Text = ComboBox9.Text Then
if anyofthose 3 happens then
turn them to red
if not,
turn them to black
end
end
why will they never happen.
cause if they those combbox.text arent the same they will turn to the colour black?
Quote Originally Posted by ppl2pass View Post
I need help for the code highlighted in red.
Code:
            If ComboBox7.Text = ComboBox8.Text Or ComboBox7.Text = ComboBox9.Text Or ComboBox8.Text = ComboBox9.Text Then
            MessageBox.Show("You have two or more of the same perk.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
            If ComboBox7.Text = ComboBox8.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox8.ForeColor = Color.Red
            ElseIf ComboBox7.Text = ComboBox9.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            ElseIf ComboBox8.Text = ComboBox9.Text Then
                ComboBox8.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            Else
                ComboBox7.ForeColor = Color.Black
                ComboBox8.ForeColor = Color.Black
                ComboBox9.ForeColor = Color.Black
            End If
        ElseIf ComboBox1.Text = ComboBox3.Text Or ComboBox1.Text = ComboBox6.Text Or ComboBox3.Text = ComboBox6.Text Then
            MessageBox.Show("You have two or more of the same weapon.", "Error!", MessageBoxButtons.OK, MessageBoxIcon******rmation)
        End If
Heres what your code does right now:
If ComboBox7.Text = ComboBox8.Text Then both boxes change colors. If that is untrue, then if ComboBox7.Text = ComboBox9.Text Then they change colors. If that is untrue then if ComboBox8.Text = ComboBox9.Text Then they change colors. Finally, if that is untrue then they all turn black.
What you need is:
Code:
'If box 7 and 8 are equal, they change to red. If not, they change to black.
            If ComboBox7.Text = ComboBox8.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox8.ForeColor = Color.Red
            Else
                ComboBox7.ForeColor = Color.Black
                ComboBox8.ForeColor = Color.Black
            End If
'If box 7 and 9 are equal, they change to red. If not, they change to black.
          If ComboBox7.Text = Combobox9.Text Then
                 ComboBox7.ForeColor = Color.Red
                 ComboBox9.ForeColor = Color.Red
          Else
                 ComboBox7.ForeColor = Color.Black
                 ComboBox9.ForeColor = Color.Black
         End If

'If box 8 and 9 are equal, they change to re. If not, they change to black.
            If ComboBox8.Text = ComboBox9.Text Then
                ComboBox8.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            Else
                ComboBox8.ForeColor = Color.Black
                ComboBox9.ForeColor = Color.Black
            End If
Right?
We should just have a sticky that says

Help ppl2pass

You make 5 new threads, Mpgh.net VB section is essentially writing everything for your uber duber releases

in all seriousness though, try to maintain one thread , especially if the content or question is similar to the last. You must be the winner for threadstarter of the day
at least he keeps this section up and running
meh, don't misunderstand me, I enjoy helping. And I am glad this section is active, even if it's by two people , I am simply stating as the minion of the section, similar content should be kept in similar threads, a thread tin regards to ElseIf (in a sense) was created not 20 mins before this.
makes the section more active
Quote Originally Posted by scimmyboy View Post
makes the section more active
Even though you have been [banned] , I'll still respond.

This section has more posts / Views then C++
Don't even respond to Justin, isn't worth the hassle.
Quote Originally Posted by Invidus View Post
Lol. I don't get it.. How is he talking is he's banned. WTF?
Obviously he posted that before he got banned.
here is the problem for this code shark23

Code:
'If box 7 and 8 are equal, they change to red. If not, they change to black.
            If ComboBox7.Text = ComboBox8.Text Then
                ComboBox7.ForeColor = Color.Red
                ComboBox8.ForeColor = Color.Red
            Else
                ComboBox7.ForeColor = Color.Black
                ComboBox8.ForeColor = Color.Black
            End If
'If box 7 and 9 are equal, they change to red. If not, they change to black.
          If ComboBox7.Text = Combobox9.Text Then
                 ComboBox7.ForeColor = Color.Red
                 ComboBox9.ForeColor = Color.Red
          Else
                 ComboBox7.ForeColor = Color.Black
                 ComboBox9.ForeColor = Color.Black
         End If

'If box 8 and 9 are equal, they change to re. If not, they change to black.
            If ComboBox8.Text = ComboBox9.Text Then
                ComboBox8.ForeColor = Color.Red
                ComboBox9.ForeColor = Color.Red
            Else
                ComboBox8.ForeColor = Color.Black
                ComboBox9.ForeColor = Color.Black
            End If
this will never work. what if box8 = box9 then those boxes will turn red but also black because it the other two arguments goes makes this statement useless.
fixed it myself using different method. lock plz.
it seems to me.. your method of doing this is over coded. Im not 100% what exactly your trying to do?
Quote Originally Posted by XGelite View Post
it seems to me.. your method of doing this is over coded. Im not 100% what exactly your trying to do?
Never like looking at the if then statements for VB. For being a high-level language it reminds me too much of a script. I don't understand why they would do it like that.

@NextGen1: And that's because C++ section has less noobs. Isn't that right ppl2pass.
Posts 1–15 of 16 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us