dcsimg
Results 1 to 8 of 8
  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    If else coding help!

    Hello
    I want to make a program with if else, I wanna get True in the text box when ComboBox1 and ComboBox2 are True and a green color in the text box.

    here is a screenshot that tells what I want, it's not the final design and test!
    https://scontent.fjrs4-1.fna.fbcdn.n...d9&oe=5AE68DE3

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: If else coding help!

    forgot to post the code:
    Dim ComboBox1 As Boolean
    Dim ComboBox2 As Boolean
    Dim TextBox1 As Boolean
    TextBox1 = Val(TextBox1)
    If (ComboBox1 = True And ComboBox2 = True) Then
    textbox1 = "True"
    End
    PS: sorry

  3. #3
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    497

    Re: If else coding help!

    Where is the value of ComboBox1 ad ComboBox2 obtained?
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.7.2)

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,516

    Re: If else coding help!

    Try this
    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If ComboBox1.Text = "True" AndAlso ComboBox2.Text = "True" Then
                TextBox1.Text = "True"
                TextBox1.BackColor = Color.Green
            Else
                TextBox1.Text = "False"
                TextBox1.BackColor = Color.Red
            End If
        End Sub



  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,811

    Re: If else coding help!

    Thread moved from the 'Maths forum' to the 'VB.Net' (VB2002 and later) forum

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: If else coding help!

    Quote Originally Posted by 4x2y View Post
    Try this
    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If ComboBox1.Text = "True" AndAlso ComboBox2.Text = "True" Then
                TextBox1.Text = "True"
                TextBox1.BackColor = Color.Green
            Else
                TextBox1.Text = "False"
                TextBox1.BackColor = Color.Red
            End If
        End Sub
    Thanks
    Last edited by casper.mta; Jan 13th, 2018 at 03:26 PM.

  7. #7
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,516

    Re: If else coding help!

    Quote Originally Posted by casper.mta View Post
    Thanks this worked good, I have a questions
    Does this works for "or" things?
    It is easily for VB.NET to detect syntax errors, so of course it will work as i don't see any syntax errors, but VB.NET cannot detect logic error!

    You need to ask yourself first what you want? And is not like Or, And needs all conditions to be True while Or needs any condition to be True

    Please enclose your code in [ code][ /code] tags



  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: If else coding help!

    Quote Originally Posted by 4x2y View Post
    It is easily for VB.NET to detect syntax errors, so of course it will work as i don't see any syntax errors, but VB.NET cannot detect logic error!

    You need to ask yourself first what you want? And is not like Or, And needs all conditions to be True while Or needs any condition to be True

    Please enclose your code in [ code][ /code] tags
    Thank you a lot! I made all things that I want

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
By using this site, you agree to the Privacy Policy