Results 1 to 20 of 20

Thread: [RESOLVED] Simple if statement problem

Hybrid View

  1. #1

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Resolved [RESOLVED] Simple if statement problem



    I'm trying to create a soccer prediction program for someone else on another forum. I've managed to do the easy bit, just slightly confused over what to do next.
    Points are given out for every result you predict correctly, with bonus points on offer if you get the correct scoreline as well
    • 2 points are won for guessing the correct result, i.e. Home win, Away win, or Draw.
    • 3 extra points for guessing the correct scoreline

    Those are the rules.

    The preson will enter the predicted scorelines in one set of textboxes, and then enters the real scorelines in another set of text boxes.
    Click me to see form


    VB Code:
    1. Private Sub cmdcalculate_Click()
    2.  
    3. Dim totalpoints As Integer
    4.  
    5. If user1.Text = real1.Text And user2.Text = real2.Text Then
    6.     totalpoints = 5
    7. End If
    8.  
    9. lbloutput.Caption = totalpoints
    10.  
    11. End Sub

    That works fine if they predict the first scoreline correctly, but I'm stuck on what code to use for the correct result.
    Any help?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Welcome to the forums.

    I'm not completely sure I understand your question, so this may be way off, but it appears to me as though you are asking how to have them select Home Win, Away Win and Draw. Is that correct?

    If so, you could you a group of three option buttons.

  3. #3

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    In essence, yes.

    Would I still be able to have the correct scoreline option if I used option buttons as well?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Quote Originally Posted by dragonskin
    In essence, yes.

    Would I still be able to have the correct scoreline option if I used option buttons as well?
    On the surface, it appears to me as though you have the scoreline figured out all ready. What effect would selecting one of the option buttons have on that?

  5. #5

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    I'm not sure, that's why I was asking you

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Quote Originally Posted by dragonskin
    I'm not sure, that's why I was asking you
    No effect that I can see.

    The only thing is that you will probably want to save, or display, their option button choice.

  7. #7

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    Cheers for the help so far

    VB Code:
    1. If Option1 = True And Option4 = True Then
    2.     totalpoints = 2
    3. If Option1 = True And Option4 = True And user1.Text = real1.Text And user2.Text = real2.Text Then
    4.     totalpoints = 5
    5. End If
    6. End If
    That works fine, is there a quick way to do it for the other games as well or will I have to write out those if statements each time?

  8. #8

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    I can store it in an Access database.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Quote Originally Posted by dragonskin
    I can store it in an Access database.
    Yes, I know you can, but will you be?

    This is your application, not mine. What do you want to do with it?

  10. #10

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    Yes, I will be

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Quote Originally Posted by dragonskin
    Yes, I will be
    Ok. It seems pretty simple. One table with a field for game name, scoreline and result.

    You might want to add a fourth field for date played. If you want to get real fancy, you could add another field and put the name of the field or stadium it was played in.

    What you store is really up to you.

  12. #12

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    New problem, trying to connect to my database and it's telling me there's a Syntax error in FROM clause

    VB Code:
    1. Public Sub loadrecordset(localrecordset As ADODB.Recordset, sql As String)
    2.  
    3. localrecordset.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    4.         "Data Source=" & App.Path & "\test -1.mdb;"
    5.    
    6. localrecordset.CursorType = adOpenKeyset
    7.     localrecordset.LockType = adLockOptimistic
    8.  
    9. localrecordset.Open sql, , adOpenForwardOnly, adLockOptimistic, adCmdText
    10.  
    11. End Sub
    It's always worked in the past

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple if statement problem

    Where would your FROM clause be?

  14. #14

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    Ignore that, a simple rename of the table did the trick

  15. #15

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    Why not?

    Option1 indicates a predicted home win
    Option4 indicates an actual home win

  16. #16
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Simple if statement problem

    Quote Originally Posted by dragonskin
    Why not?

    Option1 indicates a predicted home win
    Option4 indicates an actual home win
    Two option buttons can not both be True at the same time unless they are in different containers (like a frame or picturebox).

  17. #17

    Thread Starter
    New Member dragonskin's Avatar
    Join Date
    Dec 2005
    Location
    Wales
    Posts
    10

    Re: Simple if statement problem

    I'm having one of those 'blonde' days

  18. #18

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