line disappears while moving

I have been helped t sort the code for moving a line
I can now move the line, but it seems to disappear while I’m dragging it
it only re-appears when I stop dragging

my code:

mouse down:
  // save in a check box so I can see it's happened
  mouseDownState.Value = True
  mouseDownState.refresh
  
  // save start coords
  mouseXstart.Text = str(x)
  mouseYstart.Text = str(y)
  mouseXstart.Refresh
  mouseYstart.Refresh
  
  // save line start and end Y
  lineY1start.text = str(sunlightLine.y1)
  lineY2start.text = str(sunlightLine.y2)
  return true

mouse drag:
  dim newY as integer
  
  // show drag coordinates
  Main.mouseX.Text = str(x)
  Main.mouseY.Text = str(y)
  Main.mouseX.Refresh
  Main.mouseY.Refresh
  
  // reposition line as mouse moves
  // only moves in y direction
  newY = y - val(Main.mouseYstart.Text)
  Main.mouseYnew.Text = str(newY)
  Main.mouseYnew.Refresh
  sunlightLine.Y1 = val(LineY1start.text) + newY
  if sunlightLine.Y1 < 50 + sunlightLine.BorderWidth/2 then
    sunlightLine.Y1 =  50 + sunlightLine.BorderWidth/2
  end if
  if sunlightLine.Y1 > 100 then
    sunlightLine.Y1 = 100
  end if
  sunlightLine.Y2 = sunlightLine.Y1
  sunlightLine.refresh

  // adjust neighbour lines as well
  sunriseLine.Y2 = sunlightLine.Y1
  sunsetLine.Y1 = sunlightLine.Y1
  sunriseLine.refresh
  sunsetLine.refresh

how do I get the line to move smoothly and not disappear while being dragged

(side info - when I only had one line it was fine - now I have more than one, it doesn’t look so good)
cheers
Mike

I don’t see where you are drawing the line to start with.

FYI… It should be in the PAINT event of a canvas, or onto a PICTURE object that is then being slapped onto a canvas (if not you are on the wrong track to start with)

also… use INVALIDATE instead of REFRESH … you will get better performance

The line starts life in the IDE
I’ll give your suggestions a try
Cheers
Mike