VB画坐标轴方法:
Private Sub Form_paint()
Dim i, j As Integer
Me.CurrentX = 0
Me.CurrentY = 0
Print 0
Me.ScaleMode = 3
Me.Line (0, 0)-(0, 3000)
Me.Line (0, 0)-(3000, 0)
For i = 100 To 3000 Step 100
Me.Line (i, 0)-(i, 10)
temp = i
CurrentX = i - TextWidth(temp) / 2
Print i
Next
For i = 100 To 3000 Step 100
Me.Line (0, i)-(10, i)
temp = i
CurrentY = i - TextHeight(temp) / 2
Print i
Next
End Sub
加箭头
Private Sub Form_paint()
Dim i, j As Integer
Me.CurrentX = 10
Me.CurrentY = 10
Print 0
Me.ScaleMode = 3
Me.Line (10, 10)-(10, 600)
Me.Line (10, 10)-(600, 10)
For i = 100 To 500 Step 100
Me.Line (i, 10)-(i, 20)
temp = i
CurrentX = i - TextWidth(temp) / 2
Print i
Next
For i = 100 To 500 Step 100
Me.Line (10, i)-(20, i)
temp = i
CurrentY = i - TextHeight(temp) / 2
Print i
Next
Me.Line (590, 20)-(600, 10) 'x箭头
Me.Line (590, 0)-(600, 10) 'x箭头
Me.Line (0, 590)-(10, 600) 'y箭头
Me.Line (20, 590)-(10, 600) 'y箭头
End Sub
Private Sub Form_Click()
Dim x!, y!, i%
Form1.Scale (-9, 9)-(9, -9)
Form1.Line (-8, 0)-(8, 0)
Form1.Line (0, 8)-(0, -8)
CurrentX = 7: CurrentY = 1.3: Print "X"
CurrentX = 0.2: CurrentY = 7.3: Print "Y"
For i = -7 To 7 'X轴坐标
Line (i, 0)-(i, 0.3)
CurrentX = i - 0.2
CurrentY = -0.1
Print i
Next i
For i = -7 To 7 'Y轴坐标
Line (0, i)-(0.3, i)
CurrentX = -0.5
CurrentY = i - 0.2
Print i
Next i
For x = -2 To 4 Step 0.001
y = x ^ 2 - 2 * x + 1
PSet (x, y)
Next x
End Sub