|
-
May 5th, 2002, 09:34 PM
#1
Thread Starter
Lively Member
line method questions
I am doing a program using the line method for my VB class. The scale height and width are each set to 100. Then I am supposed to draw a line that goes from (0,100) up to (100,0), then down again to (175,100), back up to (187.5, 0), and so on. We are supposed to halve the remaining horizontal distance with each new line, until the distance on the right side is less than 0.25.
When I use these specifications, I only get one diagonal line on the screen. I don't understand how I can draw a line up to 175,100 and see it on the screen, if I have set the scale height and width to 100 each. Am I missing something? Is there a typo in my assignment from class? Is it supposed to be 75 instead of 100? I got a zigzag line when I changed it to 75.
Also, is the form actually set up like Cartesian x,y coordinates? Should I draw a graph on paper to get a better sense of this?
This is what I have for code so far, but little has happened:
Picture1.ScaleHeight = 100
Picture1.ScaleWidth = 100
Picture1.Line (0, 100)-(100, 0)
Picture1.Line (100, 0)-(175, 100)
Picture1.Line (175, 100)-(187.5, 0)
-
May 5th, 2002, 09:48 PM
#2
Also, is the form actually set up like Cartesian x,y coordinates? Should I draw a graph on paper to get a better sense of this?
Just thought I'd throw this in for you:
MSDN
Draws lines and rectangles on an object.
Syntax
object.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]
The Line method syntax has the following object qualifier and parts:
Part Description
object Optional. Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
Step Optional. Keyword specifying that the starting point coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
(x1, y1) Optional. Single values indicating the coordinates of the starting point for the line or rectangle. The ScaleMode property determines the unit of measure used. If omitted, the line begins at the position indicated by CurrentX and CurrentY.
Step Optional. Keyword specifying that the end point coordinates are relative to the line starting point.
(x2, y2) Required. Single values indicating the coordinates of the end point for the line being drawn.
color Optional. Long integer value indicating the RGB color used to draw the line. If omitted, the ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
B Optional. If included, causes a box to be drawn using the coordinates to specify opposite corners of the box.
F Optional. If the B option is used, the F option specifies that the box is filled with the same color used to draw the box. You cannot use F without B. If B is used without F, the box is filled with the current FillColor and FillStyle. The default value for FillStyle is transparent.
Remarks
To draw connected lines, begin a subsequent line at the end point of the previous line.
The width of the line drawn depends on the setting of the DrawWidth property. The way a line or box is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.
When Line executes, the CurrentX and CurrentY properties are set to the end point specified by the arguments.
This method cannot be used in an With…End With block.
-
May 5th, 2002, 10:00 PM
#3
PowerPoster
tHE REASON you're getting problems is that you've set the .ScaleWidth/.ScaleHeight to 100, and your first Line command goes to points 0,100 and 100,0 - at the corners of the box, as per the w/h you set.
You need to make the .ScaleWidth = 1000 or something.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
May 5th, 2002, 10:07 PM
#4
Thread Starter
Lively Member
Yeah, I set the scale height and width to 100 because that is what it says in the assignment. But there is no way it can work with the measurements given - should I assume that it is just a typo on the assignment? I have no clue... My teacher never answers our emails.
-
May 5th, 2002, 10:10 PM
#5
PowerPoster
Yeah, assume typo or misinformation - because it's not possible to draw the line you want in a box that's only 100 units wide. Your first zig already fills the box.
Try setting the scalewidth to 1000.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
May 5th, 2002, 10:18 PM
#6
Thread Starter
Lively Member
The lines are really small at 1000 - it looks better at 500, maybe I will go with that.
What does it mean, halving the remaining horizontal distance each time? I know what that means but I don't see how the line measurements given in this assignment correspond to it. If in fact they are correct...There isn't anything that looks like it is being divided in half.
-
May 5th, 2002, 10:23 PM
#7
PowerPoster
Is this the sample you were given:
Picture1.Line (0, 100)-(100, 0)
Picture1.Line (100, 0)-(175, 100)
Picture1.Line (175, 100)-(187.5, 0)
?
If so, I think you may have missed a line ->
Picture1.Line (0, 100)-(100, 0)
Picture1.Line (100, 0)-(150, 100)
Picture1.Line (150, 100)-(175, 0)
Picture1.Line (175, 0)-(187.5, 100)
(I had to change the next two as well).
In this case, the distance across goes:
100, 50, 25, 12.5.... etc
It's halving. Do you see?
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
May 5th, 2002, 10:29 PM
#8
Thread Starter
Lively Member
I see it now, but that line wasn't there in the example we were given.
-
May 5th, 2002, 10:42 PM
#9
PowerPoster
Well judging from the other info you've given, I'd put it down to another typo...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
May 5th, 2002, 10:45 PM
#10
Thread Starter
Lively Member
Probably so. Maybe my VB teacher was doing Jello shots while preparing our take-home final... In any case, it is working now.
-
May 5th, 2002, 10:46 PM
#11
PowerPoster
LOL 
Have fun.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
May 5th, 2002, 10:52 PM
#12
Thread Starter
Lively Member
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|