Results 1 to 4 of 4

Thread: [RESOLVED] VB6 - Check if a line (graphic) exists

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Resolved [RESOLVED] VB6 - Check if a line (graphic) exists

    I'm writting a code to create a grid inside the picturebox http://dret.net/lectures/web-spring09/img/grid.png
    I want to check if a line has been already drawn.
    I create a line called Line1(0). Then the program executes the funcion
    Code:
     Load Line1(x)
    .
    When I resize the form I call again to the function
    Code:
     Load Line1(x)
    to add lines in the picturebox.
    If I charge the line1(2) twice the programs shows the next error: "The object has been already charged".

    I want to know 2 things:
    A) How the program can knows if a line exists to prevent to charge it again
    B) What I've to write to remove a line from the picturebox. If Load Line1(X) is to create, what is the opposite function that removes a specific line?

  2. #2
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: VB6 - Check if a line (graphic) exists

    I want to know 2 things:
    A) How the program can knows if a line exists to prevent to charge it again
    B) What I've to write to remove a line from the picturebox. If Load Line1(X) is to create, what is the opposite function that removes a specific line?
    A) You need to keep track of those objects that you've drawn. Line in this case.
    B) It depends: You can redraw the picturebox without the line (either directly or from a back buffer), or
    redraw the line ontop of itself with the background color. or
    XOR the line.
    If you opt for redrawing the line with the background color you will holes in any other objects if the line was drawn on-top of those objects. XORing the line will also create holes.

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: VB6 - Check if a line (graphic) exists

    Use LineName.Count property to know if that line is already loaded or not, for example if Line1.count = 2 then Line1(0) and Line1(1) are already loaded, if you need a 3rd line you'll have to Load Line1(2). Implementation depends on your code.

    Load line1(line1.Count-1) will load the next line after the last one loaded.

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

    Re: VB6 - Check if a line (graphic) exists

    When I resize the form I call again to the function Load Line1(x)

    Is this because if the Form get bigger you want to add more lines?

    Then by same token if the Form get smaller would you want to remove lines?


    If Load Line1(X) is to create, what is the opposite function that removes a specific line?

    Unload Line1(x). I think un means to undo, don't you?
    Last edited by jmsrickland; Aug 28th, 2012 at 06:54 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.

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