非常简单,我已经自行解决了。'打印--是否显示滚动条 Public Declare Function GetScrollRange Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long Public Const SB_VERT = &H1 Public Function ShowScroll(hwnd As Long) As Boolean '判断垂直滚动条的可见性 Dim i As Long i = GetScrollRange(hwnd, SB_VERT, lpMinPos, lpMaxPos) ShowScroll = (lpMaxPos <> lpMinPos) End FunctionPrintDataForm窗体 dyyl 这是richtextbox 控件Public Sub printdata(sj As String) Dim st As Long, cd As Long, l As Long, ym As Long On Error GoTo 89 st = 1 cd = 1 ym = 1 l = Len(sj) With PrintDataForm.dyyl Do If st + cd - 1 > l Then .Text = Mid$(sj, st, cd - 1) PrintDataForm.Label1.Caption = "第 " & ym & " 页" PrintDataForm.PrintForm Unload PrintDataForm GoTo 88 Else .Text = Mid$(sj, st, cd) If ShowScroll(.hwnd) Then cd = cd - 1 .Text = Mid$(sj, st, cd) PrintDataForm.Label1.Caption = "第 " & ym & " 页" PrintDataForm.Caption = ShowScroll(.hwnd) PrintDataForm.PrintForm Unload PrintDataForm ym = ym + 1 st = cd + 1 cd = 1 If st > l Then GoTo 88 Else cd = cd + 1 End If End If Loop End With 88 Exit Sub 89 MsgBox "对不起,可能您还没有安装打印机,或者打印机配置不正确,无法打印!"
Public Declare Function GetScrollRange Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Public Const SB_VERT = &H1
Public Function ShowScroll(hwnd As Long) As Boolean '判断垂直滚动条的可见性
Dim i As Long
i = GetScrollRange(hwnd, SB_VERT, lpMinPos, lpMaxPos)
ShowScroll = (lpMaxPos <> lpMinPos)
End FunctionPrintDataForm窗体
dyyl 这是richtextbox 控件Public Sub printdata(sj As String)
Dim st As Long, cd As Long, l As Long, ym As Long
On Error GoTo 89
st = 1
cd = 1
ym = 1
l = Len(sj)
With PrintDataForm.dyyl
Do
If st + cd - 1 > l Then
.Text = Mid$(sj, st, cd - 1)
PrintDataForm.Label1.Caption = "第 " & ym & " 页"
PrintDataForm.PrintForm
Unload PrintDataForm
GoTo 88
Else
.Text = Mid$(sj, st, cd)
If ShowScroll(.hwnd) Then
cd = cd - 1
.Text = Mid$(sj, st, cd)
PrintDataForm.Label1.Caption = "第 " & ym & " 页"
PrintDataForm.Caption = ShowScroll(.hwnd)
PrintDataForm.PrintForm
Unload PrintDataForm
ym = ym + 1
st = cd + 1
cd = 1
If st > l Then GoTo 88
Else
cd = cd + 1
End If
End If
Loop
End With
88 Exit Sub
89 MsgBox "对不起,可能您还没有安装打印机,或者打印机配置不正确,无法打印!"
免费的源码、工具网站,欢迎大家访问!
http://www.j2soft.cn/
═══════════════════