473,387 Members | 3,033 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,387 software developers and data experts.

If Statment Help

Hi.

I'm currently developing a self-test application to be used by the staff at my school (SDD assignment), and I've hit a snag. I've created around 7 different "base" forms, each of which will be inherited for the particular questions that are going to be asked to the user.

Now, I created some subroutines to easily create those question forms. All you have to do to load a form is type in, say:

Createform_Mchoice(formID, Question, answer1, answer2, answer3, answer4, answerCondition)

The question and multiple choice answers will then be automatically filled into a new form dimensioned. I then have a subroutine for the "Next Question" button on each form, which is meant to test the "AnswerCondition" and if it is true then award a point to a variable. The answer condition changes for every form, so for example I would make it "chk1.Checked = True".

Now when I put this condition into an If statement, it comes up with a conversion error.

For example,

If strAnswerCondition Then Word_GeneralResult += 1

The error states that it cannot convert a string (strAnswerCondition) to boolean.

What do I do?
Aug 31 '08 #1
4 902
jg007
283 100+
Sorry, I am a little unclear on what you are trying to do but if you are using a string you will need to have something like -

If strAnswerCondition = "<TEXT>" Then Word_GeneralResult += 1

otherwise you will need

if stranswerquestion1.checked then Word_GeneralResult += 1

the fact that you have called it stranswercondition implies that it is a string in which case you cannot check it for a true/false as it is not a boolean value.
Aug 31 '08 #2
jg007
283 100+
looking again I would guess that you would be better passing the correct answer number to the function then getting it to return a boolean value for if it is correct

sorry my programming is really messy so I won't try to provide an example as I tried to create this with two forms and ended up with a bizzare mess of a function and a timer control on form1 to check when to change the question text on form2 <:)
Aug 31 '08 #3
Hey, thanks for replying.

The thing is, I have several different forms which the correct answer can take. In one form, it can be one of four options, another 0-4 of four options, another an actual text answer typed in by the user etc.


Would I be able to, for each specific form type, pass at least the actual answers instead of the whole condition? For example, instead of passing "opt1.Checked = True" inside strAnswerCondition to the Next Button subroutine, pass "opt1.Checked" and then have the "= True" in the actual subroutine. Or pass "chk1.Checked And chk2.Checked" to the subroutine.

Will this work, or will it come up with another conversion error?

And if it won't work, is there any other solution you can think of, or is there a way to instruct the compiler to actually read the string strAnswerCondition literally (ie. read the text inside as program code, not as a string)?
Sep 1 '08 #4
jg007
283 100+
Sorry, I'm still a little bit usure what you are doing and the question you are asking , would it be possible to post some of the code for how the form is called and the nextbotton event


are you actually checking the answers when the users press next or are you storing them into an array or something to be checked at the end?
Sep 1 '08 #5

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

Similar topics

1
by: e_AK_05 | last post by:
I have a question and I can't figure out how to do it. I have a select statment : SELECT table1.* AS table1.*, table2.* AS table2.* FROM table1, table2 WHERE 1 this does not work...for me at...
9
by: Appel | last post by:
Hallo i have a problem to add to string with a SQL statement. My Table : Tablename NAMES: | Name1 | Name2 | Name3 | John Meyer I search for a SQL statment that update Name3.
8
by: 73blazer | last post by:
Hello, I'm looking for a way to make some of my insert templates more readable by placing comments in between the values. I cannot seem to find a way to do this with DB2, is there a way? I'm...
1
by: Me, Myself, and I | last post by:
First off, i apologize if my terminology is off... I am currently in a project that is basically a front-end to a database. In coding this, I am taking into account that it has the *potential*...
1
by: Anton Nikiforov | last post by:
Dear All, could you please help me with writing select statment for the following: I have two tables dictionary_text label| Text -----+------------------------ 23 | General 24 | Internet...
2
by: Denis Correard | last post by:
I have an application that create an insert statment on the fly (it would be to complex to create stored procedures for all senarios) like: insert into Table (field1, field2,field3 ,field4 ) VALUES...
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
3
by: miss time | last post by:
hi can any one help me pleaseto understand about if statment because Idid not really understood this topic from teacher and i will have final exam after few day thank you
1
by: shivendravikramsingh | last post by:
hello friends, actually i have a problem in using conditional statement in ajax function i m tring to describe my problem properly,what i want when i select a value form a combo its vlue is passed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.