-
Aug 14th, 2013, 03:06 PM
#1
Thread Starter
Junior Member
edit causes compile error
I get this error:
compile error
wrong amount of arguments or invalid property assignment:
This is highlighted : .Line (X1, Y1)-(X2,
in the next to last statement below after I make any change in any staement
Below, I changed: b = txt(1)
to b = 45: 'txt(1)
and the error popped up.
The change seems totally unrelated to the line highlighted and remains even after I end the program.
The compile error shows immediately when I hit F5 (run)
if I close the app (Alt F X) and restart there is no compile error even with the changed statement.
This means that after each edit, I must save and close then reopen the project !!!
lAngle = txt(3)
b = 45: 'txt(1)
h = txt(2)
lAngle = lAngle / 180 * 3.14159625 ' Convert to radians
X1 = 0: Y1 = 0
X2 = X1 + Cos(lAngle) * b
Y2 = Y1 + Sin(lAngle) * h
Picture1.Line (X1, Y1)-(X2, Y2)
Picture1.Line (0, 0)-(h - Sin(lAngle * Pi / 180), 0)
-
Aug 14th, 2013, 03:16 PM
#2
Re: edit causes compile error
Interesting...copied your code exact...no errors (except I substituted 60 for txt(2))
Able to complile, run, F5, etc...no problems. Don't know what to tell you, except maybe start a NEW project and try it.
-
Aug 14th, 2013, 03:29 PM
#3
Re: edit causes compile error
No compile errors. No run time errors. I'm assuming you initialize Pi somewhere else otherwise it will be Empty
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Aug 14th, 2013, 03:35 PM
#4
Re: edit causes compile error
Prof
Below, I changed: b = txt(1)
to b = 45: 'txt(1)
and the error popped up.
This line looks confusing to me ...
b = 45: 'txt(1)
1. Why do you have a colon after 45?
2. Why do you apparently comment out txt(1) .. ie, an apostrophe before txt(1)?
Spoo
Last edited by Spoo; Aug 14th, 2013 at 03:40 PM.
-
Aug 14th, 2013, 03:47 PM
#5
Re: edit causes compile error
well, you would use a colon to put multiple commands on the same line:
Code:
Dim b as Integer, z as integer
b=45:b=b*2:z=b-10
But since the next "line" is a comment... I wonder if that actually works... but it's not how I would have done it in the first place, but eh...
-tg
-
Aug 14th, 2013, 04:12 PM
#6
Re: edit causes compile error
He first had
b = txt(1)
then he changed it to
b = 45:'txt(1)
This is not a problem nor is it confusing. A colon after a statement is perfectly valid. An apostrophe before a statement is also perfectly valid
Last edited by jmsrickland; Aug 14th, 2013 at 04:15 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Aug 14th, 2013, 04:12 PM
#7
Re: edit causes compile error
Originally Posted by jmsrickland
No compile errors. No run time errors. I'm assuming you initialize Pi somewhere else otherwise it will be Empty
Not being a math major, not really interested in what direction the OP's line went, I did NOT initialize Pi, nor any of the other variables. I turned off Option Explicit just to run the code. I guess I could turn it back on and try again.
-
Aug 14th, 2013, 04:16 PM
#8
Re: edit causes compile error
Nope, dimmed all variables, set pi to 3.141414.....ran it, no errors (with or without the colon after the 45
-
Aug 14th, 2013, 04:18 PM
#9
Re: edit causes compile error
Originally Posted by SamOscarBrown
Not being a math major, not really interested in what direction the OP's line went, I did NOT initialize Pi, nor any of the other variables. I turned off Option Explicit just to run the code. I guess I could turn it back on and try again.
You get Variable not defined on first statement. Maybe that's his error; he didn't say what kind of error.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Aug 14th, 2013, 04:55 PM
#10
Re: edit causes compile error
yeah, lAngle...I dimmed it as an integer (for this simple test), and no problem.
-
Aug 14th, 2013, 05:38 PM
#11
Re: edit causes compile error
Originally Posted by jmsrickland
This is not a problem nor is it confusing. A colon after a statement is perfectly valid. An apostrophe before a statement is also perfectly valid
Well you are 1/2 right It is valid but it is confusing as there is absolutely no reason to use a : there and the use of it makes you expect to see another statement on that line where there is just a comment and therefore no need for the :
As for the error message I would look at what variable types are being used for X1,Y1 and X2,Y2.
-
Aug 14th, 2013, 06:39 PM
#12
Re: edit causes compile error
Well, I sure don't want to be half right so I will restate my post...
This is not a problem nor is it confusing [to me]. A colon after a statement is perfectly valid. An apostrophe before a statement is also perfectly valid
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Aug 15th, 2013, 08:54 AM
#13
Re: edit causes compile error
TG and DataMiser
Yes, thanks for better stating my source of confusion.
I was drawn to it as the OP indicated that when those changes were made, his compile error began.
But I agree, too, with JMS .. while nominally confusing, it nonetheless should not cause an error
Spoo
-
Aug 15th, 2013, 09:00 AM
#14
Re: edit causes compile error
ok... so I went back to the first post....
Code:
lAngle = txt(3)
b = 45: 'txt(1) ' < --- HERE is the "change"
h = txt(2)
lAngle = lAngle / 180 * 3.14159625 ' Convert to radians
X1 = 0: Y1 = 0
X2 = X1 + Cos(lAngle) * b
Y2 = Y1 + Sin(lAngle) * h
Picture1.Line (X1, Y1)-(X2, Y2) '< --- But HERE is the error....
Picture1.Line (0, 0)-(h - Sin(lAngle * Pi / 180), 0)
OK... so let's look at that.... if that second bolded line is where the error happens, then clearly X1, X2, Y1, or Y2 is an incorrect value... something tells me that it's going to be X2 that has a value that exceeds the limits of what it can be...
so back to the OP ... At the time of the error, what are the values of the following variables?
b: ______
h: ______
lAngle: ______
X2: ______
-tg
-
Aug 15th, 2013, 09:09 AM
#15
Re: edit causes compile error
I've had the same trouble with the Line methods over the years.
There's nothing wrong with your code, it's just VB "being VB".
Try moving the troublesome code out into a separate function, that you don't need to change very often, and you'll have a lot less problems (I won't go as far as to say "none", but it'll be less ).
Regards, Phill W.
-
Aug 15th, 2013, 09:27 AM
#16
Thread Starter
Junior Member
Re: edit causes compile error
Originally Posted by Phill.W
I've had the same trouble with the Line methods over the years.
There's nothing wrong with your code, it's just VB "being VB".
Try moving the troublesome code out into a separate function, that you don't need to change very often, and you'll have a lot less problems (I won't go as far as to say "none", but it'll be less ).
Regards, Phill W.
Thanks, Phill
I believe that you are correct because if I save the edit then close the project and run it again with the change, it runs without any problem. Also, I recall, also, that the .line (and also .scale) did the same thing happened a long time ago.
Usually after an edit, either vb6 takes it or cautions that the edit would require a reset. With the .line statement, however, any edit, will highlight part of that statement and refuse to run until you reset.
Thanks again Phill.
-
Aug 15th, 2013, 09:33 AM
#17
Re: edit causes compile error
ok... hang on one cotton picking second there.... WHEN are you doing these "edits?" while the code is "ruinning" ... or at design time? The only reason you should get that reset message is if you're pausing the code, and then making changes...
I give up. I'm done with this thread.
-tg
Tags for this Thread
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
|