|
-
Apr 9th, 2000, 01:32 PM
#1
Thread Starter
Member
i have an command button array of 42 buttons. every once in a while in the click event i get this 'expression too complex' error. the line of code is
ElseIf Int(cmdDay(Index).Caption) < 15 Then
i am using an error handling add in. the add in picks up the error and kicks out of the sub. now if i set my options to break on all errors it will break on that line and then i can continue with out changing anything. it is almost as if the machine doesnt feel like doing that line of code at that moment. i know that is not possible but i have no other explanation.
also on every 8 clicks of the array i get the error 'invalid procedure call or argument' on the line
myMonth = Format(inString, "mmmm")
instring is passed into the routine as a valid date string and mymonth is a local variable declared as a string.
any ideas why i get these random errors.
-
Apr 9th, 2000, 01:42 PM
#2
Hyperactive Member
Hi JJK,
First off... there is no such thing as a "random" error. What may look random on the surface means only that you do not know all the factors that goes into making the error occur. (Basic Complexity Theory).
Without seeing the code that surrounds what you are talking about it is a little hard to work out what the problem is as I get a gut feeling that some of your problems are caused outside of the exact area where you see the problem. Often with Visual Basic it will report to you the line that falls over but the problem is another line that set things in motion to fall over where it did.
The first thing I would be doing is getting rid of the "Int" function and replacing it with a "Val" function. The reason for this is that Int was designed for finding the integer of a number more so than converting a string into an integer. Yes it does work fine but Val works better at converting strings into integers.
Secondly. If "inString" is a string then trying to format your string into that of a date is doing a lot of implicit or non-existant conversions. Try doing a "Format(DateValue(inString),"mmmm") instead. By doing this you are only converting from a date to a month instead of trying to let Format convert the string inString to a Date and then grab the month out of it... I believe it will fail because it can't turn a String into a Month.
See if that helps.
-
Apr 9th, 2000, 06:29 PM
#3
Junior Member
Val isn't that good actually. (It dates back to BASIC). I would use one the of the CDbl, CSng, CLng, CInt etc, because they are smarter. They skip over commas (as in 10, 000) and are generally better.
-
Apr 10th, 2000, 06:51 AM
#4
Hyperactive Member
Philosopher....
How about you go and try this...
CInt("20-asd")
I think when Visual Basic Crashes into a heap you will find that Val is MUCH more useful in a situation when you cannot GUARANTEE that the string you are getting is in fact nothing but digits and its placeholders.
Don't you agree?
-
Apr 11th, 2000, 01:08 AM
#5
Junior Member
Gen-X. I just posted a reply like that to annoy you (you are very easily annoyed). Nice to see it worked.
See ya!
-
Apr 11th, 2000, 10:56 AM
#6
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|