473,513 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparison Operators

Hi
I need to average the two highest numerics entered in separate text
boxes using an if statement.

So far I have got

if txtFirst.Text >= txtSecond.text and txtFirst.Text >= txtThird.text
then
FirstHigh = txtFirst.text
elseif
txtSecond.Text >= txtFirst.text and txtSecond.Text >= txtThird.text
then
FirstHigh = txtSecond.text
elseif

txtThird.Text >= txtFirst.text and txtThird.Text >= txtSecond.text
then
FirstHigh = txtThird.text

This gives me which is the Highest. My problem is to get the second
highest value.

Please help

Carlob1
Nov 20 '05 #1
3 1176
* ca****@global.co.za (Carlo) scripsit:
I need to average the two highest numerics entered in separate text
boxes using an if statement.


First, enable 'Option Explicit' and 'Option Strict'.

Then, convert the texts to numeric datatypes and add them to an
'ArrayList'. After doing that, call its 'Sort' method.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #2
first i would suggest that you convert to numeric values before compairing
now you could end up w 99 being bigger then 100
2nd
try using an arraylist

like this
Dim int As New ArrayList

int.Add(CInt(txt1.text))

int.Add(CInt(txt2.text))
....
int.Sort()

Dim i As Integer = int.Count

intlargest = int(i - 1)

int2ndlargest = int(i - 2)

hope it helps

eric

"Carlo" <ca****@global.co.za> wrote in message
news:bf*************************@posting.google.co m...
Hi
I need to average the two highest numerics entered in separate text
boxes using an if statement.

So far I have got

if txtFirst.Text >= txtSecond.text and txtFirst.Text >= txtThird.text
then
FirstHigh = txtFirst.text
elseif
txtSecond.Text >= txtFirst.text and txtSecond.Text >= txtThird.text
then
FirstHigh = txtSecond.text
elseif

txtThird.Text >= txtFirst.text and txtThird.Text >= txtSecond.text
then
FirstHigh = txtThird.text

This gives me which is the Highest. My problem is to get the second
highest value.

Please help

Carlob1

Nov 20 '05 #3
Carlo,
I need to average the two highest numerics entered in separate text
boxes using an if statement.
Is the "if" statement a requirement (of the homework assignment?) or just
the only way you know how? As the Sort method the others pointed to is the
"easiest", alternatively you could use an insertion sort when you put the
values into the ArrayList, or simply use a SortedList.

If the "if" statement is a requirement:

Once you have the FirstHigh, to find the second you need to find the highest
text box (as before), that is lower then FirstHigh.

To find the third you need to find the highest text box (as before) that is
lower then the SecondHigh... and so on...

Hope this helps
Jay

"Carlo" <ca****@global.co.za> wrote in message
news:bf*************************@posting.google.co m... Hi
I need to average the two highest numerics entered in separate text
boxes using an if statement.

So far I have got

if txtFirst.Text >= txtSecond.text and txtFirst.Text >= txtThird.text
then
FirstHigh = txtFirst.text
elseif
txtSecond.Text >= txtFirst.text and txtSecond.Text >= txtThird.text
then
FirstHigh = txtSecond.text
elseif

txtThird.Text >= txtFirst.text and txtThird.Text >= txtSecond.text
then
FirstHigh = txtThird.text

This gives me which is the Highest. My problem is to get the second
highest value.

Please help

Carlob1

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5390
by: Michael Klatt | last post by:
I've just encountered a strange situation (at least to me) regarding friend operators and member operators: #include <map> class Key { friend bool operator<(const Key& lhs, const Key& rhs) { return lhs.myInt < rhs.myInt;
13
4582
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and which also implements ==, <, <=, >, >=, etc. (Those operators are tested and working correctly.) If I assign map = "world", it saves the...
29
2593
by: Steven D'Aprano | last post by:
Playing around with comparisons of functions (don't ask), I discovered an interesting bit of unintuitive behaviour: >>> (lambda y: y) < (lambda y: y) False Do the comparison again and things become even more bizarre: >>> (lambda y: y) < (lambda y: y) True
2
2039
by: PengYu.UT | last post by:
I'm wonder whether 1. stl directly defined the 6 comparison operators(== != < > <= >=) directly for iterator and const_iterator 2. or it only define == and < and using std::rel_ops to get the other 4 operators. I made the following example for case 1. But I can not make it work. Could you please help me to make it work. Thanks,
1
5087
by: Thats Me | last post by:
TMALSS: Task With maintenance of Access Database I did not develop, don't ask about non-commented code problems or where data dictionary is (LOL). Have table with Inventory data for all Publications held, contains binder number on shelf and is text data in numeric/alpha form i.e.; 123, 1234, 123a, 1234c. I want to stuff the last...
2
2592
by: Serve La | last post by:
Now that implementations are becoming available, I've started to learn more about C99. Now I was reading about the isgreater/isgreaterequal/isless/... macro's and I'm wondering about why they are here? What's the difference with the normal relational operators?
37
2762
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current behaviour, which is returning a value which is, really, id({}) < id(). He also said that default equality comparison will continue to be identity-based....
17
2013
by: Dinsdale | last post by:
I would like to compare a string value to a pre-determined list of other strings. Is there a simple way to do this in one statements like this: if(strMystring.ToUpper() == ("STRING1"| "STRING2"| "STRINGX")) {} This syntax doesn't work (and in fact I'm not quite sure what this statement really is saying) but I'd like to be able to do...
2
2734
by: Mark Rae | last post by:
Hi, This isn't *specifically* an ASP.NET question, so I've also posted it in the ADO.NET group - however, it's not too far off-topic... Imagine a SQL Server 2005 database with a table with an int column used for bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc intBitwise strName ----------------------
2
3011
by: puzzlecracker | last post by:
Unlike C++, in Csharp you're only allowed to compare a generic type T with null, if the method it's passed in not implementing IComparable<Tor , IEquatable<T(still don't know why we need these two radically similar interfaces). In other words, Csharp enforces people to not make mistake, whereas C++ follows the philosophy "if you make a...
0
7270
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5704
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.