473,387 Members | 1,721 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.

How do I use equal to or less then in VB

147 100+
I am trying to the following but it stops priot to completion:

Expand|Select|Wrap|Line Numbers
  1. ......
  2. Case rs!Rank = "6" And Forms!frmOverTime!YearsInRank < 1
  3. stRateOfPay = "Ptlm1"
  4. Case rs!Rank = "6" And Forms!frmOverTime!YearsInRank > 1 = 2 < 3
  5. stRateOfPay = "Ptlm2"
  6. ..........
  7.  
At line 3 it checks that Forms!frmOverTime!YearsInRank is greater then 1 and stops there and fils the dtat under line 4 in my form. It is not continuing to check if it is equal to 2 and less then 3 and continuing on if it is. What am I doing wrong?????

Thanks
Jan 20 '09 #1
12 1893
ChipR
1,287 Expert 1GB
I think you are using the Case incorrectly. You can have

Select Case rs!Rank
Is = 6 'or "6" for text
Select Case Forms!frmOverTime!YearsInRank 'or just use If
etc.

Each clause in the case statement is going to compare to whatever you Select. Pretty sure you can't combine them with AND.
Jan 20 '09 #2
DAHMB
147 100+
It actually looks like this:


Expand|Select|Wrap|Line Numbers
  1. Select Case True
  2. Case rs!Rank = "6" And Forms!frmOverTime!YearsInRank < 1
  3. stRateOfPay = "Ptlm1"
  4. Case rs!Rank = "6" And Forms!frmOverTime!YearsInRank > 1 = 2 < 3
  5. stRateOfPay = "Ptlm2"
  6.  
Any ideas?
Jan 20 '09 #3
ChipR
1,287 Expert 1GB
Let me try that again with code tags.

Expand|Select|Wrap|Line Numbers
  1. Select Case rs!Rank
  2.     Is = 6 'or "6" for text
  3.         Select Case Forms!frmOverTime!YearsInRank 'or just use If
  4.     etc.
Sorry I hit TAB the first time and posted prematurely.
Jan 20 '09 #4
DAHMB
147 100+
My problem is with the comparison at the end it s not fully checking the value of Forms!frmOverTime!YearsInRank to se if it is less than 1 or equal or greater than 2 but less than 3.
Jan 20 '09 #5
ChipR
1,287 Expert 1GB
You might be able to put And Forms!frmOverTime!YearsInRank in between each of those, or just write an if statement. The syntax is just wrong. I've never used Select Case True. Is that a common practice?
Jan 20 '09 #6
DAHMB
147 100+
I have no idea, I was using elseIf but someone else pointed me to use select case.
Jan 20 '09 #7
ChipR
1,287 Expert 1GB
Actually, why would you say "greater than 1 and equal to 2 and less than 3" instead of simply "equal to 2"?
Jan 20 '09 #8
DAHMB
147 100+
good point I was using months before and canned that idea. I am movving on to another angle.

Thanks
Jan 20 '09 #9
NeoPa
32,556 Expert Mod 16PB
@ChipR
No Chip.

It is however very flexible and powerful ;)

Select Case is a very flexible and clear way of splitting the logic. It can handle multiple splits more clearly than multiple Ifs or even ElseIfs.

What can sometimes be a limitation is that the checks are not always done on the same items, even when the splitting of the logic all happens in one place. This is where the Select Case True comes in.

Think about it. The first of the Case statements to resolve to True will be selected when run. Elegant and supremely flexible.

Dan's code was actually quite valid (in its concept at least).
Jan 26 '09 #10
NeoPa
32,556 Expert Mod 16PB
@DAHMB
I'm assuming you're talking about your line #4 here?

Can you say exactly what you're looking for in Forms!frmOverTime!YearsInRank? Can we also assume that this figure will be integral (whole numbers only)?
Jan 26 '09 #11
In Line 4, do all of those conditions need to be true? PErhaps you need to break that up with an AND or an OR

Forms!frmOverTime!YearsInRank > 1 AND/OR Forms!frmOverTime!YearsInRank = 2 AND/OR Forms!frmOverTime!YearsInRank < 3

Where AND/OR is either AND or OR. Just a thought.

Steve
Jan 27 '09 #12
NeoPa
32,556 Expert Mod 16PB
Steve's point is very likely to be right for your situation. Clarification of my earlier point would help us to be sure.

Assuming then that it is so for now, this leaves us looking to find a way to reduce all the referencing in Forms!frmOverTime!YearsInRank.

Would this code be running within the frmOverTime module anyway by any chance? If so, then Me.YearsInRank (or even more simply YearsInRank alone) would be a simpler and shorter way of referring to the same object.
Jan 27 '09 #13

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

Similar topics

9
by: Hebar Tiltwobler | last post by:
I need to figure out if the current date (passed in as a string) is equal to or greater then a field in my database in the format of- M/D/YYYY AND if the date is less then another field in my...
5
by: William Payne | last post by:
Hi, I was going through some old code of mine and spotted this: if(i == 16 || i == 32 || i == 48 || i == 64 || i == 80 || i == 96 || i == 112 || i == 128 || i == 144 || i == 160 || i == 176 || i...
1
by: Propel Exacto | last post by:
Hey guys, I am using MySQL 4.0.18 and I have a field named "order_datetime" in which I store data in the format 20041001 23:00:00 (for example Oct 1, 2004 11pm) When I do a select statement...
4
by: Jeremy Howard | last post by:
Hello everyone, I'm not a database guru so I'm sorry if this is a dumb question but here it goes... I have this sql query that I'm trying to run against a table on a Sql 2k server: SELECT ...
15
by: Murt | last post by:
Hi, when writing equations in vb .net, how do you enter the signs "less than or equal to" etc. thanks Murt
0
by: Nik Coughlin | last post by:
Something that I've been trying to do for a long time is a 3 column layout where all three columns have equal height, and have rounded corners implemented using PNGs with alpha. One of my early...
6
kamill
by: kamill | last post by:
I need to generate a report (with fromdate and todate).If we set the “from” date and “to” dates as the same it should generates a report for that date. If we set the “from” date as one day before...
11
by: Bernard.Mangay | last post by:
The remainder is non zero due to rounding errors. How can I remove the rounding errors?
12
by: Slaunger | last post by:
Hi, I am new here and relatively new to Python, so be gentle: Is there a recommended generic implementation of __repr__ for objects equal by value to assure that eval(repr(x)) == x independet...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.