首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

print怎么自动折行

2012-09-24 
print如何自动折行?picture1.print 123216545613214687654321357435434132132当picture宽度不够时候后面

print如何自动折行?
picture1.print "123216545613214687654321357435434132132"

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


[解决办法]
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


试试这个
[解决办法]
按每行字符数截取print就行

[解决办法]

VB code
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 sEnd SubPrivate Sub Form_Load()    Picture1.Width = 3000End Sub
[解决办法]
无法自动,必须代码
[解决办法]
顶一个
[解决办法]
由于PICTUREBOX有边框,可以每行减少一个字
VB code
Option ExplicitPrivate Sub Form_Load()Command1_ClickEnd SubPrivate 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 sEnd Sub
[解决办法]
VB code
Option ExplicitPrivate Sub Form_Load()Command1_ClickEnd SubPrivate 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 sEnd Sub
[解决办法]
VB code
改成函数Option ExplicitPrivate Sub Form_Load()Dim S As String   S = "123216545613214687一二三四五六七八九十中国12345678901234567890123456789012345678901234567890一二三四五六七八九十"ShowTxtInPic Picture1, SEnd 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 SEnd Function 

热点排行
Bad Request.