473,396 Members | 1,965 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,396 software developers and data experts.

Is it posible to use multiple vars in one if-statement?

1
I've got a question about multiple vars in one if-statement.

I'm trying to use multiple vars in an if-statement but i got a few error because I don't really know how to use it.

I would lite to check if 4 vars are the same as other 4 vars, but I don't want to use 9 if-statement because I need to check it every second in my program

sample:

Expand|Select|Wrap|Line Numbers
  1. if (var1, var2, var3, var4 < var5, var6, var7, var8)
  2. {
  3.     return(true);
  4. }
I know that the "," won't work.

Is there a way to this? or do I have to use multiple if-statements?
Feb 10 '11 #1
1 1383
hype261
207 100+
From your code it is difficult to see which logic you are trying to produce, but you need to use the && and || operators.

The && operator stands for "and" and will return true if both arguments are true. If either argument is false or both arguments are false then it will return false.

The || operator stands for "or" and will return true if one or both of the arguments are true. It will only return false if both arguments are false.

I am assuming the logic you are going for, but here is some sample code...

Expand|Select|Wrap|Line Numbers
  1. if ( var1 < var5 && var2 < var6 && var3 < var7 && var4 < var8)
  2. {
  3. return true;
  4. }
  5.  
Feb 10 '11 #2

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

Similar topics

11
by: nephish | last post by:
Hello there, i need a way to check to see if a certain value can be an integer. I have looked at is int(), but what is comming out is a string that may be an integer. i mean, it will be formatted...
1
by: NAT | last post by:
I am using session mode as "InProc"(entered in web.config). I have deployed my ASP.NET appln. on a server which uses Load Balancer. i.e I have two servers. I am using session across pages.The...
1
by: Gary | last post by:
I'm writing a simple program to dish out incoming leads. I don't understand database programming in c# and this needs to be finished like yesterday - so i dont have the luxury of spending a...
1
by: jjuan | last post by:
I have a multiple dropdown which have multiple selection. If I select multiple value on my multiple dropdown list and submit it,how can i write it on the tblotherlang sample code <select...
16
by: devicerandom | last post by:
Hi, I am currently using the Cmd module for a mixed cli+gui application. I am starting to refactor my code and it would be highly desirable if many commands could be built as simple plugins. ...
9
by: beary | last post by:
Given that I'm trying to automate the process of uploading 20-30 files at a time (and I have to do this regularly), and the filenames are always the same each time (eg. it's always file1.gif,...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
21
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 {...
2
by: kevcar40 | last post by:
Hi is it posible to check if another database is open? i have several datasbase the first is a dbase where the local data is maintained on closing the database the table is exported to a holding...
1
dlite922
by: dlite922 | last post by:
without babbling too much here's what I'm looking for: printf("%s is the same as %s","A Duck") to output "A Duck is the same as A Duck"; But of course, if you know how to use it, to get...
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:
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.