picture1.print "123216545613214687654321357435434132132"当picture宽度不够时候后面的就没有显示了
如何用简单的方法能实现自动折行

解决方案 »

  1.   

    Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    试试这个
      

  2.   

    按每行字符数截取print就行
      

  3.   


    Private Sub Command1_Click()
       s = "123216545613214687一二三四五六七八九十12345678901234567890123456789012345678901234567890一二三四五六七八九十"
       With Picture1
          For i = 1 To Len(s)
              If .TextWidth(Mid(s, 1, i)) > .Width Then
                  Picture1.Print Mid(s, 1, i - 1)
                  s = Mid(s, i): i = 1
              End If
          Next
       End With
        If s <> "" Then Picture1.Print s
    End SubPrivate Sub Form_Load()
        Picture1.Width = 3000
    End Sub
      

  4.   

    由于PICTUREBOX有边框,可以每行减少一个字
    Option ExplicitPrivate Sub Form_Load()
    Command1_Click
    End Sub
    Private Sub Command1_Click()
    Dim s As String, i As Integer
       s = "123216545613214687一二三四五六七八九十12345678901234567890123456789012345678901234567890一二三四五六七八九十"
       With Picture1
          For i = 1 To Len(s)
              If .TextWidth(Mid(s, 1, i + 1)) > .Width Then
                  Picture1.Print Mid(s, 1, i - 1)
                  s = Mid(s, i): i = 1
              End If
          Next
       End With
        If s <> "" Then Picture1.Print s
    End Sub
     
     
      

  5.   

    Option ExplicitPrivate Sub Form_Load()
    Command1_Click
    End Sub
    Private Sub Command1_Click()
    Dim s As String, i As Integer
       s = "123216545613214687一二三四五六七八九十中国12345678901234567890123456789012345678901234567890一二三四五六七八九十"
       With Picture1
          For i = 1 To Len(s)
              If .TextWidth(Mid(s, 1, i)) > .ScaleWidth Then
                  Picture1.Print Mid(s, 1, i - 1)
                  s = Mid(s, i): i = 1
              End If
          Next
       End With
        If s <> "" Then Picture1.Print s
    End Sub
     
      

  6.   

     改成函数
    Option ExplicitPrivate Sub Form_Load()
    Dim S As String
       S = "123216545613214687一二三四五六七八九十中国12345678901234567890123456789012345678901234567890一二三四五六七八九十"
    ShowTxtInPic Picture1, S
    End SubFunction ShowTxtInPic(Picture1, S)
    Dim I As Long
       With Picture1
          For I = 1 To Len(S)
              If .TextWidth(Mid(S, 1, I)) > .ScaleWidth Then
                  Picture1.Print Mid(S, 1, I - 1)
                  S = Mid(S, I): I = 1
              End If
          Next
       End With
        If S <> "" Then Picture1.Print S
    End Function