PC Review


Reply
Thread Tools Rate Thread

Compare the "varchar" values

 
 
Tim
Guest
Posts: n/a
 
      11th Jan 2010
I need to compare the student's score with the requirement score. The problem
is the score is either a varchar value, i.e., "2" OR is combined by two
varchar values, such as "2" and "+" or "-" like "2+". If a student's score is
lower then the req score then the student is not qualified. How to compare
them in VBA?
Thank you in advance for your help.
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      11th Jan 2010
I would force the values to increase or decrease based on the presence of the
+ and - signs and then compare the numeric values. Using Replace and Eval you
could use an expression like the following for the comparison.

Eval(Replace(Replace(Score,"+","+.1"),"-","-.1")) >=
Eval(Replace(Replace(Required,"+","+.1"),"-","-.1"))

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Tim wrote:
> I need to compare the student's score with the requirement score. The problem
> is the score is either a varchar value, i.e., "2" OR is combined by two
> varchar values, such as "2" and "+" or "-" like "2+". If a student's score is
> lower then the req score then the student is not qualified. How to compare
> them in VBA?
> Thank you in advance for your help.

 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      13th Jan 2010
Thanks a lot. It's smart way to deal with this specific issue.

"John Spencer" wrote:

> I would force the values to increase or decrease based on the presence of the
> + and - signs and then compare the numeric values. Using Replace and Eval you
> could use an expression like the following for the comparison.
>
> Eval(Replace(Replace(Score,"+","+.1"),"-","-.1")) >=
> Eval(Replace(Replace(Required,"+","+.1"),"-","-.1"))
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> Tim wrote:
> > I need to compare the student's score with the requirement score. The problem
> > is the score is either a varchar value, i.e., "2" OR is combined by two
> > varchar values, such as "2" and "+" or "-" like "2+". If a student's score is
> > lower then the req score then the student is not qualified. How to compare
> > them in VBA?
> > Thank you in advance for your help.

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compare "varchar" values? Tim Microsoft Access VBA Modules 2 13th Jan 2010 03:26 AM
Compare two worksheets with "contains" and not "exact" values Fuzzy Microsoft Excel Worksheet Functions 1 4th Oct 2009 07:27 AM
Compare to a range of values using "from/to" =?Utf-8?B?TGlzYSBPLg==?= Microsoft Excel Misc 7 23rd May 2006 07:00 PM
Compare value to array of values, "best fit" (closest without going over, e.g. price is right) KR Microsoft Excel Programming 3 11th Jan 2005 06:51 PM
compare ranges in different workbooks and copy "not matching values" at bottom of range 1 Kaza Sriram Microsoft Excel Programming 1 6th Aug 2004 07:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.