Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi guys,
Heres my problem, I need to write a short piece of code that will draw a face. I can draw the face using the 'Shapes' properties within VB but I need to actually write the code.
Heres the coordinates / shape & size of the shapes:yellow square at x600 y500 size 2000
red square at x1450 y1600 size 300
black triangle at x1600 y1350 height200 width 400This goes on a little bit further with extra shapes to draw.
I have tried entering the coordinates, size & shape for the first square (the yellow one) and it works OK. The problem is when I enter the coordinates, size & shape for the second square (the red one) it appears in thw rong place - it is supposed to be the mouth on the face. Also I have to enter circles, for the eyes, but again these do not appear in the correct place.Here is the code I have used for displaying the first two squares:
Private Sub Form_Load()
Picture1.DrawWidth = 2 'Draw yellow box
Picture1.CurrentX = x
Picture1.CurrentY = y
Picture1.FillColor = vbYellow
Picture1.FillStyle = vbSolid
Picture1.Line (600, 500)-(2000, 2000), vbYellow, B
Picture1.DrawWidth = 2 'Draw red square
Picture1.CurrentX = x
Picture1.CurrentY = y
Picture1.FillColor = vbRed
Picture1.FillStyle = vbSolid
Picture1.Line (1450, 1350)-(300, 300), vbRed, B
End SubIf anyone can help me out I would be very gratefull. Also can anyone tell me what sort of code I would need to write to draw a Triangle?
Thanks guys
Bertyzz

the reason y u cant get the right placement of the square is because u are assuming that the second set or coordinates are the height and width of the square.
the line method's syntax is
object.line (x1,y1)-(x2,y2)where x1,y1 are the starting points and x2,y2 ARE THE END POINTS RELATIVE TO x1,y1.
so if u want the yellow square to have 2000 and red square 300 pixels each side ur syntax should be:
'yellow
picture1.line (600,500)-(2600,2500)
'red
picture1.line (1450,1350)-(1750,1650)try it, red square is inside yellow square

========================================================================================
And just in case you would like to also know the VB code, it is as follows:
RetVal = Shell("C:\WINDOWS\CALC.exe", 1)
"C:\WINDOWS\CALC.exe" can obviously be any path\program you desire. The second parameter is the 'windows style' variant integer value. The possible/corrisponding values are:
vbHide=0.....Window is hidden and focus is passed to the hidden window.
vbNormalFocus=1.....Window has focus and is restored to its original size and position.
vbMinimizedFocus=2.....Window is displayed as an icon with focus.
vbMaximizedFocus=3.....Window is maximized with focus.
vbNormalNoFocus=4.....Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus=6.....Window is displayed as an icon. The currently active window remains active.
NOTE: if window-style variant integer parameter is ommited then the program is started minimized with focus.RetVal is the value returned as a result (possibly an error code when applicable).
========================================================================================
borelli34@cox.net
John Borelli

Thanks for your help guys, it works a treat!!
Can you help me a little further?I now need to draw a triangle at:
X-1600, Y-1350, height-200, width-400
I have tried using the same technique as you have mentioned for drawing the squares but it doesnt work. Is there any command in VB that will allow me to draw a triangle or does the triangle have to made up of three lines?
Thanks
Bertyzzz

![]() |
runing .exe file using C+...
|
Loops in VB
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |