|
-
Dec 20th, 2005, 12:21 PM
#1
Thread Starter
New Member
[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:
Private Sub cmdcalculate_Click()
Dim totalpoints As Integer
If user1.Text = real1.Text And user2.Text = real2.Text Then
totalpoints = 5
End If
lbloutput.Caption = totalpoints
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?
-
Dec 20th, 2005, 12:27 PM
#2
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.
-
Dec 20th, 2005, 12:31 PM
#3
Thread Starter
New Member
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?
-
Dec 20th, 2005, 12:33 PM
#4
Re: Simple if statement problem
 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?
-
Dec 20th, 2005, 12:35 PM
#5
Thread Starter
New Member
Re: Simple if statement problem
I'm not sure, that's why I was asking you
-
Dec 20th, 2005, 12:47 PM
#6
Re: Simple if statement problem
 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.
-
Dec 20th, 2005, 01:45 PM
#7
Thread Starter
New Member
Re: Simple if statement problem
Cheers for the help so far
VB Code:
If Option1 = True And Option4 = True Then
totalpoints = 2
If Option1 = True And Option4 = True And user1.Text = real1.Text And user2.Text = real2.Text Then
totalpoints = 5
End If
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?
-
Dec 20th, 2005, 01:57 PM
#8
Re: Simple if statement problem
 Originally Posted by dragonskin
Cheers for the help so far
VB Code:
If Option1 = True And Option4 = True Then
totalpoints = 2
If Option1 = True And Option4 = True And user1.Text = real1.Text And user2.Text = real2.Text Then
totalpoints = 5
End If
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?
Store or display the name of the game along with these. You only have to have this one bit of code (at least from what I understand), so somewhere you would need to have a place (maybe a textbox) that provided the opportunity to log a name.
I re-read your original question. Are you planning on storing this data somewhere? If so where?
-
Dec 20th, 2005, 02:27 PM
#9
Thread Starter
New Member
Re: Simple if statement problem
I can store it in an Access database.
-
Dec 20th, 2005, 02:30 PM
#10
Re: Simple if statement problem
 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?
-
Dec 20th, 2005, 02:33 PM
#11
Thread Starter
New Member
Re: Simple if statement problem
Yes, I will be
-
Dec 20th, 2005, 02:35 PM
#12
Re: Simple if statement problem
 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.
-
Dec 20th, 2005, 02:42 PM
#13
Thread Starter
New Member
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:
Public Sub loadrecordset(localrecordset As ADODB.Recordset, sql As String)
localrecordset.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\test -1.mdb;"
localrecordset.CursorType = adOpenKeyset
localrecordset.LockType = adLockOptimistic
localrecordset.Open sql, , adOpenForwardOnly, adLockOptimistic, adCmdText
End Sub
It's always worked in the past
-
Dec 20th, 2005, 02:44 PM
#14
Re: Simple if statement problem
Where would your FROM clause be?
-
Dec 20th, 2005, 02:50 PM
#15
Thread Starter
New Member
Re: Simple if statement problem
Ignore that, a simple rename of the table did the trick
-
Dec 20th, 2005, 03:28 PM
#16
Fanatic Member
Re: Simple if statement problem
 Originally Posted by dragonskin
Cheers for the help so far
VB Code:
If Option1 = True And Option4 = True Then
totalpoints = 2
If Option1 = True And Option4 = True And user1.Text = real1.Text And user2.Text = real2.Text Then
totalpoints = 5
End If
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?
you cant have 2 option buttons true at the same time
-
Dec 20th, 2005, 03:47 PM
#17
Thread Starter
New Member
Re: Simple if statement problem
Why not?
Option1 indicates a predicted home win
Option4 indicates an actual home win
-
Dec 20th, 2005, 04:06 PM
#18
Re: Simple if statement problem
 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).
-
Dec 20th, 2005, 04:11 PM
#19
Thread Starter
New Member
Re: Simple if statement problem
I'm having one of those 'blonde' days
-
Dec 20th, 2005, 04:15 PM
#20
Re: Simple if statement problem
Another point is that checkboxes are normally used when several things can be true at the same time.
BTW I have senior moment days
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|