Results 1 to 13 of 13
  1. #1
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry

    [HELP] 2 ifs in 1 if. [Solved]

    Hey all, i'm working on a program, wich has to change from picture on some mouseclicks. heres my code:

    Code:
    Declare Function GetKeyState Lib "user32.dll" (ByVal KeyCode As Long) As Integer
        Const VK_LBUTTON = &H1
        Const VK_RBUTTON = &H2
    
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic2
            ElseIf GetAsyncKeyState(VK_RBUTTON) & GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic4
            ElseIf GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
        End Sub
    now everthing works fine, except for this code:
    Code:
    ElseIf GetAsyncKeyState(VK_RBUTTON) & GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic4
    i want it to change to pic4, when i click L AND R button, but when i do, it just changes to pic2....

    Any help please?
    Last edited by Acinonyx Backup; 03-03-2011 at 07:55 AM.
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  2. #2
    kumpelblase2's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    NIE, Germany
    Posts
    18
    Reputation
    10
    Thanks
    20
    My Mood
    Relaxed
    change the "&" to "and" . should work





  3. #3
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry
    omg :O i'll try

    naha, not working
    Last edited by Acinonyx Backup; 03-03-2011 at 08:15 AM.
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  4. #4
    karldeovbnet's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    Malabon City
    Posts
    11
    Reputation
    10
    Thanks
    2
    My Mood
    Amazed
    how bout changing it to this, just a hunch

    Code:
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then
                
                       If GetAsyncKeyState(VK_RBUTTON)
                                  Form3.BackgroundImage = My.Resources.pic4
                       Else
                                  Form3.BackgroundImage = My.Resources.pic2  
    
            ElseIf GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
        End Sub
    i think the problem is, it already went inside the 1st if, so it will make it pic2, it doesnt have the chance to check 2nd if condition,

    if u want, u can make the 1st if condition to check if L and R is press, then the 2nd if is for if L is pressed
    Last edited by karldeovbnet; 03-03-2011 at 08:27 AM.
    VB.Noob

    i'm here to learn and contribute as much as i can to the community

    ~ako si karl deo~

  5. #5
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry
    i'll try thx
    you need 2 end if's ofc.
    Error 1 'ElseIf' must be preceded by a matching 'If' or 'ElseIf'.

    Error 2 'Else' must be preceded by a matching 'If' or 'ElseIf'.
    Last edited by Acinonyx Backup; 03-03-2011 at 08:41 AM.
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  6. #6
    karldeovbnet's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    Malabon City
    Posts
    11
    Reputation
    10
    Thanks
    2
    My Mood
    Amazed
    Quote Originally Posted by Acinonyx Backup View Post
    i'll try thx
    you need 2 end if's ofc.
    Error 1 'ElseIf' must be preceded by a matching 'If' or 'ElseIf'.

    Error 2 'Else' must be preceded by a matching 'If' or 'ElseIf'.
    Code:
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
    
            If GetAsyncKeyState(VK_LBUTTON) Then
                
                       If GetAsyncKeyState(VK_RBUTTON)
                                  Form3.BackgroundImage = My.Resources.pic4
                       Else
                                  Form3.BackgroundImage = My.Resources.pic2  
                       End If < Forgot to add this end if
    
            ElseIf GetAsyncKeyState(VK_RBUTTON) Then
    
                Form3.BackgroundImage = My.Resources.pic3
    
            Else
    
                Form3.BackgroundImage = My.Resources.pic1
    
            End If
    
        End Sub
    or using ur original code:

    Code:
    Declare Function GetKeyState Lib "user32.dll" (ByVal KeyCode As Long) As Integer
        Const VK_LBUTTON = &H1
        Const VK_RBUTTON = &H2
    
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then < make this 2nd condition
                Form3.BackgroundImage = My.Resources.pic2
            ElseIf GetAsyncKeyState(VK_RBUTTON) & GetAsyncKeyState(VK_LBUTTON) Then < make this 1st condition
                Form3.BackgroundImage = My.Resources.pic4
            ElseIf GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
        End Sub
    Last edited by karldeovbnet; 03-03-2011 at 08:45 AM.
    VB.Noob

    i'm here to learn and contribute as much as i can to the community

    ~ako si karl deo~

  7. The Following User Says Thank You to karldeovbnet For This Useful Post:

    Acinonyx Backup (03-03-2011)

  8. #7
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry
    Not working :S

    got it working myself, thx for trying to help me, thanks to you i found a way through it...

    working code:

    Code:
    If GetAsyncKeyState(VK_RBUTTON) Then
                If GetAsyncKeyState(VK_LBUTTON) Then
                    Form3.BackgroundImage = My.Resources.pic4
                Else
                    Form3.BackgroundImage = My.Resources.pic3
                End If
    
            ElseIf GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic2
            Else
                Form3.BackgroundImage = My.Resources.pic1
            End If
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  9. #8
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    That's why people mostly learn the basics before going to advanced stuff

  10. #9
    Skinnlaw's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    Netherlands
    Posts
    204
    Reputation
    -1
    Thanks
    15
    My Mood
    Amazed
    Quote Originally Posted by Acinonyx Backup View Post
    Hey all, i'm working on a program, wich has to change from picture on some mouseclicks. heres my code:

    Code:
    Declare Function GetKeyState Lib "user32.dll" (ByVal KeyCode As Long) As Integer
        Const VK_LBUTTON = &H1
        Const VK_RBUTTON = &H2
    
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic2
            ElseIf GetAsyncKeyState(VK_RBUTTON) & GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic4
            ElseIf GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
        End Sub
    now everthing works fine, except for this code:
    Code:
    ElseIf GetAsyncKeyState(VK_RBUTTON) & GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic4
    i want it to change to pic4, when i click L AND R button, but when i do, it just changes to pic2....

    Any help please?
    Try this next time:
    Code:
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic2
            Else
                 Form3.BackgroundImage = My.Resources.pic4
                 End If
            If GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
           If GetAsyncKeyState(VK_LBUTTON) and GetAsyncKeyState(VK_RBUTTON) Then
              Form3.BackgroundImage = ""
           Else
           Form3.BackGroundImage = My.Resourse.pic1
    End If
        End Sub
    'That worked for me just fine :D
    That stops you from coding with 1oo words
    Last edited by Skinnlaw; 03-03-2011 at 09:20 AM.

  11. #10
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry
    Quote Originally Posted by Hassan View Post
    That's why people mostly learn the basics before going to advanced stuff

    I actually learned the basics, and i'm known as an advanced coder @ many other forums...
    just didn't know this yet. i got stuck be4 on 2 ifs in 1, and i fixed it, but that didn't work here either :S im kinda tired aswell....

    Quote Originally Posted by Skinnlaw View Post
    Try this next time:
    Code:
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
            If GetAsyncKeyState(VK_LBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic2
            Else
                 Form3.BackgroundImage = My.Resources.pic4
                 End If
            If GetAsyncKeyState(VK_RBUTTON) Then
                Form3.BackgroundImage = My.Resources.pic3
            Else
                Form3.BackgroundImage = My.Resources.pic1
                End If
           If GetAsyncKeyState(VK_LBUTTON) and GetAsyncKeyState(VK_RBUTTON) Then
              Form3.BackgroundImage = ""
           Else
           Form3.BackGroundImage = My.Resourse.pic1
    End If
        End Sub
    'That worked for me just fine :D
    That stops you from coding with 1oo words


    Yes, i tried that b4, and that doesn't work... as you can see in the previous posts...
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  12. #11
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Acinonyx Backup View Post
    I actually learned the basics, and i'm known as an advanced coder @ many other forums...
    just didn't know this yet. i got stuck be4 on 2 ifs in 1, and i fixed it, but that didn't work here either :S im kinda tired aswell....
    Um, you can't call yourself even close to advanced if a simple If structure confuses you.

    Thread marked solved.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  13. The Following User Says Thank You to Jason For This Useful Post:

    Blubb1337 (03-04-2011)

  14. #12
    Acinonyx Backup's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    DUTCH! :)
    Posts
    51
    Reputation
    13
    Thanks
    3
    My Mood
    Angry
    Quote Originally Posted by Jason View Post


    Um, you can't call yourself even close to advanced if a simple If structure confuses you.

    Thread marked solved.
    ... im very tired... belieme or not... :S its up to you, im advanced member/moderator/advanced vb coder at many forums :S

    maybey the level of MPGH is a bit Higher
    but i can code, and its kinda bad, that i didn't solve it my own in 2 secs, ,but i'm just tired man...
    Currently banned for 1337 posts
    till 28-4-2013


    Sex is like a joke, some people get it, some people don't

  15. #13
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,669
    My Mood
    Breezy
    AndAlso
    & is used to join strings

    [highlight=vb.net]If True = True AndAlso True <> False Then MsgBox("LOL!")[/highlight]
    Last edited by master131; 03-03-2011 at 10:07 PM.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  16. The Following User Says Thank You to master131 For This Useful Post:

    ChocoBoyJr (03-04-2011)