Basic, Vis' a Vis'

      • Visual Basic 6.0: I want to draw lines in a picture box using the [line] method, but I want the lines to be in different colors. The help files give two ways:
    • using the RGB (n,n,n) method at the end of the [line] statement, or,
    • setting the pictureboxname.foreground value to one of the hex numbers in the default palette, before the [line] statement you wish it to affect.
  • My problem is, neither works. All I get is black lines; I can’t get any other color. I notice that if you try to use a hex number not in the existing (default) palette, when you try to move the cursor off that line the computer immediately returns an error. Am I doing this right? - MC

Not much of a VB guru, but here’s something you might try.

Make the lines a few points thicker. I had a similar problem once, and the color worked fine on everything except my spiderweb-thin lines…

Oh, and move the picture-box, temporarily. Make sure that the lines aren’t being drawn onto the form, then covered by the graphic.

Doubt it’ll help, but good luck anyway!

-David

Depending on the color range you need, you could use QBColor(n) instead of the RGB function.

These options certainly worked for me

Picture1.Line (iXstart, iYStart)-(iXFinish, iYFinish), RGB(iColor * 64, 0, 0)

Picture1.Line (iXstart, iYStart)-(iXFinish, iYFinish), QBColor(iColor)
I wouldn’t worry about the lines being drawn in a different colour on another control - if you can see black lines on the picture control, they won’t be getting printed anywhere else.

Noddy question - you can actually see different colours with your current configuration?
Russell

      • I can only get one color of line to show per picturebox, and only if I use drawmode #13 and change the forecolor property in the properties window. IF I try to use any three runtime methods, all I get is black lines. If I switch the drawmode style, I get odd colors showing up, in some cases, depending on the drawmode but I need several different colors. The most I get playing with the drawmode is two. Hmmmm . . . - MC