473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Iif Function

lee123
556 512MB
Hi There I've Been Doing Alot Of Projects For My Kids And This Time I Wanted To Do A Math Quiz But I Cant Figure Out How To Use The ("iif") Function For This Project. Lets See If I Can Explain This Right Because Last Time I Had A "formleader" Help Me On The Last Project And He Was Cool Can't Remember His Name But If He Reads This He'll Know Any Way I Have A Form And I Have Three Text Boxes:

1 - Number1
2 - Number2
3 - Useranswer (determins If The User Gets The Answer Right Or Wrong When He Presses Enter)


And I Have A Button Named "next" ( This Button Generates Random Numbers)


I Need Someway To Count How Many They Get Right And How Many They Get Wrong Do I Use Two Text Boxes? If So How Can I Use The ("iif") Function In Them To Count This?

Lee 123
Jun 15 '07 #1
11 2143
vkong85
24
it seems to me you can just use a query to count how many right and wrong answers ure kids get on the test at the end of the test you can just get simple report off a query and it should just tell them how many right and wrong.
Jun 15 '07 #2
lee123
556 512MB
Well I Wanted To Use The "iif" Function In The Control Source Of The Textboxes ( Correct) And ( Incorrect) But Don't Know How To Aproach It. Don't Want A Query I Want Them To See How Many They Get Right And How Many They Get Wrong.on The Form
Jun 15 '07 #3
lee123
556 512MB
is there anybody out there who can help!
Jun 16 '07 #4
FishVal
2,653 Expert 2GB
Hi There I've Been Doing Alot Of Projects For My Kids And This Time I Wanted To Do A Math Quiz But I Cant Figure Out How To Use The ("iif") Function For This Project. Lets See If I Can Explain This Right Because Last Time I Had A "formleader" Help Me On The Last Project And He Was Cool Can't Remember His Name But If He Reads This He'll Know Any Way I Have A Form And I Have Three Text Boxes:

1 - Number1
2 - Number2
3 - Useranswer (determins If The User Gets The Answer Right Or Wrong When He Presses Enter)


And I Have A Button Named "next" ( This Button Generates Random Numbers)


I Need Someway To Count How Many They Get Right And How Many They Get Wrong Do I Use Two Text Boxes? If So How Can I Use The ("iif") Function In Them To Count This?

Lee 123
Hi, Lee.

Will be glad to help you. Plz clarify the following:
  • what are the purposes of the fields mentioned ?
  • does the answers stored anyway in db table or you simply use correct/incorrect answers counters ?
  • whether the counters should be visible throughout the whole survey or after a kid has answered the last question ?
Jun 16 '07 #5
lee123
556 512MB
well the purpose of the fields are when i click on the "next" button it generates random numbers in fields: number1 and number2 then the user or my kids add up the numbers it generates, in a textbox (useranswer) and when they press enter a msgbox pops up and tell them if the number they entered in the textbox (useranswer) is "correct" or if they enter in the wrong number a msgbox pops up and say's "incorrect the correct answer is(whatever the correct answer is) I wanted to use incorrect and correct counters. and i want them visible with a percentage like 80% or 100%
Jun 16 '07 #6
FishVal
2,653 Expert 2GB
well the purpose of the fields are when i click on the "next" button it generates random numbers in fields: number1 and number2 then the user or my kids add up the numbers it generates, in a textbox (useranswer) and when they press enter a msgbox pops up and tell them if the number they entered in the textbox (useranswer) is "correct" or if they enter in the wrong number a msgbox pops up and say's "incorrect the correct answer is(whatever the correct answer is) I wanted to use incorrect and correct counters. and i want them visible with a percentage like 80% or 100%
You may do it this way.

Place on the form two additional fields for counters.
txtRightAnswersCount
txtWrong AnswersCount
set their "Format property" to "General Number" and "Visibile" property to "Yes" or "No" on your choice

Add to code where the answer is resolved to be right or wrong counter incremntig instructions
Expand|Select|Wrap|Line Numbers
  1. ..................................
  2. Me.txtRightAnswersCount=Me.txtRightAnswersCount+1
  3. ..................................
  4. Me.txtWrong AnswersCount=txtWrong AnswersCount+1
  5. ..................................
  6.  
For the fields supposed to display right/wrong percentage set "DataSource" property to
=[txtRightAnswersCount]/([txtRightAnswersCount]+[txtRightAnswersCount])*100
=[txtWrong AnswersCount]/([txtWrong AnswersCount]+[txtWrong AnswersCount])*100

Almost as in Excel, just in Access.
Jun 17 '07 #7
lee123
556 512MB
THESE CODES I USE :

Me.txtrightanswerscount = Me.txtrightanswerscount + 1
Me.txtwronganswerscount = Me.txtwronganswerscount + 1

DO I PUT THEM IN THE CONTROL SOURCE OF THE TWO TXTBOXES I NAMED "CORRECT" AND "INCORRECT" OR BEHIND THE VB CODE WINDOW OF THE USERANSWER.

I GUESS I EXPLAINED THAT RIGHT...I HOPE

LEE123
Jun 17 '07 #8
FishVal
2,653 Expert 2GB
THESE CODES I USE :

Me.txtrightanswerscount = Me.txtrightanswerscount + 1
Me.txtwronganswerscount = Me.txtwronganswerscount + 1

DO I PUT THEM IN THE CONTROL SOURCE OF THE TWO TXTBOXES I NAMED "CORRECT" AND "INCORRECT" OR BEHIND THE VB CODE WINDOW OF THE USERANSWER.

I GUESS I EXPLAINED THAT RIGHT...I HOPE

LEE123
In VBA code. If you would be so kind to post your code (particulary the part where program logic decides what msgbox to show), I will be more certain in my advices.
Jun 17 '07 #9
lee123
556 512MB
Ok this is what i got in the useranswer txtbox (afterupdate):

Dim ANSWER As Integer

ANSWER = NUMBER1 + NUMBER2

If Val(USERANSWER) = ANSWER Then
msgbox "Correct!"
Else
msgbox "Incorrect! the right answer is: " & ANSWER
End If

End Sub

this is what i got in the button i called "next" (click):


Randomize

NUMBER1 = Int(Rnd * 10 + 2)
NUMBER2 = Int(Rnd * 10 + 2)

End Sub



the code where the msgboxes are in the afterupdate
and the code for the Rnd#'s are in the click event.

lee123
Jun 17 '07 #10
FishVal
2,653 Expert 2GB
Ok this is what i got in the useranswer txtbox (afterupdate):

Dim ANSWER As Integer

ANSWER = NUMBER1 + NUMBER2

If Val(USERANSWER) = ANSWER Then
msgbox "Correct!"
Else
msgbox "Incorrect! the right answer is: " & ANSWER
End If

End Sub

this is what i got in the button i called "next" (click):


Randomize

NUMBER1 = Int(Rnd * 10 + 2)
NUMBER2 = Int(Rnd * 10 + 2)

End Sub



the code where the msgboxes are in the afterupdate
and the code for the Rnd#'s are in the click event.

lee123
Place code lines incrementing right/wrong answers counters before (or after, as you like) MsgBox callings.
Like this.

Expand|Select|Wrap|Line Numbers
  1. If Val(USERANSWER) = ANSWER Then
  2. Me.txtRightAnswersCount = Me.txtRightAnswersCount + 1
  3. msgbox "Correct!"
  4. Else
  5. Me.txtWrongAnswersCount = Me.txtWrongAnswersCount + 1
  6. msgbox "Incorrect! the right answer is: " & ANSWER
  7. End If
  8.  
Jun 17 '07 #11
lee123
556 512MB
ok i did that and i get a compile error saying that "method or data member not found" i have named the two txtboxes(controls) what you told me to name
so i don't know why it can't find it. i have also declared your code as a variable

as dim txtrightanswerscount as integers
as dim txtwronganswerscount as integers

am i suppose to declare it as dim? do you think this is getting frusturating?

lee123
Jun 17 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.