Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limits to Val Function?

Status
Not open for further replies.

Tranman

Programmer
Sep 25, 2001
695
US
Hi all,
I have a couple of fields that are built up from strings. They are both in YYYYMMDD format.

The first one is:
YMDA$, and contains a value of "20020220"
The second is:
YMDB$, and contains a value of "20000315"

When I try to compare the two by saying:

If Val(YMDA$) > Val(YMDB$) Then 'Which it clearly is
Blah, blah......
End If

Nothing happens. The program runs right by the if statement like there was nothing there. The logic is imbedded in a BIG .exe with 7 modules, and I cannot single instruct through it.

I have tried having it print the strings, and the str$ of the Vals, and the print leads me to believe that the fields contain what they are supposed to.

The only conclusion that I can come up with is that QB is not able to compare values that are that large.

ANY help would be appreciated.

Thanks,
Tranman
 

Hmm ... I dunno ... It works correctly for me using Qbasic & QB4.5.

Are you using v7.1 by any chance? If so, then are you linking with the NOFILTN.OBJ file that comes with PDS? There's a bug wih that. Linking with it result in invalid VAL() returns.

Only thing I can suggest right now is - try breaking up the IF line a bit and see if the error clears up...

y1 = VAL(YMDA$)
y2 = VAL(YMDB$)
IF y1 > y2 THEN
'blahh
END IF



- Dav
 
No, I'm using 4.5 It works ok for me when I code it in the IDE and single instruct through it, also when I compile it into an exe.

I did try assigning the VAL's to doubles and comparing them, with the same result.

The only way I have found to get it to work is to write a nested if with the year checked first, then if the years are equal, checking the MMDD. It is effective, but ugly, and does not answer the question as to why the other IF doesn't work. Makes me wonder which other IFs are also not working.

Anyway, thanks for the suggestion.

Anybody else?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top