为什么在窗体加栽时,标尺不出现,而在按下command1时,去能出现标尺?程序代码如下:
Option Explicit
Public s As IntegerPrivate Function drawVruler(Hpicture As PictureBox)
'画垂直标尺
Dim Hstep As Double
Dim Hstep1 As Double
Dim i As Integer
Dim j As Integer
'Dim s As Integer
Hstep = Hpicture.ScaleHeight / s
For i% = 1 To s
Hpicture.Line (0.5 * Hpicture.ScaleWidth, Hstep * i%)-(Hpicture.ScaleWidth, Hstep * i%)
Next
Hstep1 = Hpicture.ScaleHeight / (s * 10)
For j% = 1 To (s * 10)
   Hpicture.Line (0.8 * Hpicture.ScaleWidth, Hstep1 * j%)-(Hpicture.ScaleWidth, Hstep1 * j%)
Next
End FunctionPrivate Function drawHruler(Vpicture As PictureBox)
'画水平标尺
Dim Vstep As Double
Dim Vstep1 As Double
Dim m As Integer
Dim n As Integer
Vstep = Vpicture.ScaleWidth / s
For m% = 1 To s
 Vpicture.Line (Vstep * m%, 0.5 * Vpicture.ScaleHeight)-(Vstep * m%, -Vpicture.ScaleHeight)
 Next
Vstep1 = Vpicture.ScaleWidth / (s * 10)
For n% = 1 To (s * 10)
 Vpicture.Line (Vstep1 * n%, 0.2 * Vpicture.ScaleHeight)-(Vstep1 * n%, -Vpicture.ScaleHeight)
 Next
End FunctionPrivate Sub Command1_Click()
Picture1.Cls
Picture2.Cls
s = 4
Call drawVruler(Picture2)
Call drawHruler(Picture1)
End SubPrivate Sub Form_Load()
s = 6
Call drawVruler(Picture2)
Call drawHruler(Picture1)
End Sub
序代码如下: