Results 1 to 17 of 17

Thread: edit causes compile error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    ny
    Posts
    26

    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)

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    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.

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  4. #4
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    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.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: edit causes compile error

    Quote Originally Posted by jmsrickland View Post
    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.

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    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

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: edit causes compile error

    Quote Originally Posted by SamOscarBrown View Post
    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.

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: edit causes compile error

    yeah, lAngle...I dimmed it as an integer (for this simple test), and no problem.

  11. #11
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: edit causes compile error

    Quote Originally Posted by jmsrickland View Post
    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.

  12. #12
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  13. #13
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    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

  14. #14
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  15. #15
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    759

    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.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    ny
    Posts
    26

    Re: edit causes compile error

    Quote Originally Posted by Phill.W View Post
    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.

  17. #17
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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
  •  



Click Here to Expand Forum to Full Width