为什么第一次划就那么小, 再点一次就画得那么大?
====================================================
Private Sub Rectangle(left As Integer, top As Integer, right As Integer, bottom As Integer, color As String)
    Picture1.Line (left, top)-(right, top), color
    Picture1.Line (right, top)-(right, bottom), color
    Picture1.Line (right, bottom)-(left, bottom), color
    Picture1.Line (left, bottom)-(left, top), color
End SubPrivate Sub DrawAtable(rows As Integer, cols As Integer, color As String)
    
    Picture1.Cls
    Dim i, j, rowoffset, coloffset As Integer
    
    Call Rectangle(30, 30, 12000, 8000, color)
    
    rowoffset = (8000 - 30) / rows
    coloffset = (12000 - 30) / cols
    
    For i = 1 To rows - 1
        Picture1.Line (30, 30 + i * rowoffset)-(12000, 30 + i * rowoffset), color
    Next i
    
    For j = 1 To cols - 1
        Picture1.Line (30 + j * coloffset, 30)-(30 + j * coloffset, 8000), color
    Next jEnd Sub
'
Private Sub Command1_Click()
    '画线测试
 For i = 1000 To 5000 Step 200
    'Picture1.Line (0, i)-(8000, i), vbBlue
    'Picture1.Line Step(0, 0)-Step(i, 2000), vbBlue
 Next i'调用划线过程
Call DrawAtable(100, 100, vbBlue)
end sub
====================================================

解决方案 »

  1.   

    把 Picture1 的属性 ScaleMode 设置为 Pixel注意:
    Picture1.Line (30, 30 + i * rowoffset)-(12000, 30 + i * rowoffset),
    由于目前你用的是 缇,i * rowoffset 不一定是 Screen.TwipsPerPixelX 的整数倍。
    所以会有一个像素的差。
      

  2.   

    Private Sub Rectangle(left As Integer, top As Integer, right As Integer, bottom As Integer, color As String)
        Picture1.Line (left, top)-(right, top), color
        Picture1.Line (right, top)-(right, bottom), color
        Picture1.Line (right, bottom)-(left, bottom), color
        Picture1.Line (left, bottom)-(left, top), color
    End SubPrivate Sub DrawAtable(rows As Integer, cols As Integer, color As String)
        
        Picture1.Cls
        Dim i, j, rowoffset, coloffset As Integer
        
        Call Rectangle(2, 2, 800, 500, color)
        
        rowoffset = (500 - 2) / rows
        coloffset = (800 - 2) / cols
        
        For i = 1 To rows - 1
            Picture1.Line (2, 2 + i * rowoffset)-(800, 2 + i * rowoffset), color
        Next i
        
        For j = 1 To cols - 1
            Picture1.Line (2 + j * coloffset, 2)-(2 + j * coloffset, 500), color
        Next jEnd Sub
    '
    Private Sub Command1_Click()
        '画线测试
     For i = 1000 To 5000 Step 200
        'Picture1.Line (0, i)-(8000, i), vbBlue
        'Picture1.Line Step(0, 0)-Step(i, 2000), vbBlue
     Next i'调用划线过程
    Call DrawAtable(100, 100, vbBlue)
    End SubPrivate Sub Form_Load()
       Picture1.ScaleMode = 3
       
    End Sub