Results 1 to 4 of 4

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

  1. #1
    Lively Member
    Join Date
    Mar 12
    Posts
    127

    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
    Frenzied Member
    Join Date
    Jul 01
    Location
    Tucson, AZ
    Posts
    1,814

    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 03
    Location
    Argentina
    Posts
    4,321

    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 08
    Posts
    6,781

    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.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •