📄 testmain.frm
字号:
Password = ""
RecordSource = "政工基本信息表"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.ListBox List1
Height = 1860
ItemData = "TestMAIN.frx":030A
Left = 2655
List = "TestMAIN.frx":030C
TabIndex = 2
Top = 4350
Visible = 0 'False
Width = 2235
End
Begin VB.PictureBox MyImg
Height = 1920
Left = 2844
Picture = "TestMAIN.frx":030E
ScaleHeight = 1860
ScaleWidth = 2430
TabIndex = 1
Top = 7452
Visible = 0 'False
Width = 2496
End
Begin VB.CommandButton Command1
BackColor = &H00C0FFC0&
Caption = "打印预览"
Height = 345
Left = 6540
Style = 1 'Graphical
TabIndex = 0
ToolTipText = "打印预览"
Top = 5820
Width = 1260
End
Begin VB.Label Label1
BackColor = &H00C0C0C0&
BackStyle = 0 'Transparent
Caption = "请选择要打印的栏目:"
ForeColor = &H00FF0000&
Height = 240
Left = 240
TabIndex = 4
Top = 150
Width = 2355
End
End
Attribute VB_Name = "万能表格"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim STR_SQL As String
Dim Line_tf As Boolean
Private Sub Command1_Click()
Static l As Integer, rPnt As Integer, A As String
Dim i, ii As Integer
Dim Str_txt, str_Field As String
Dim Field_COUNT, Rec_Count, Page_Count, ll, W_space As Integer
Paper_W = PAPERW
Paper_H = PAPERH
If List3.ListCount = 0 Then
MsgBox "请注意:您未选择打印所需栏目,请您选择后再继续!", 48, "提示"
Exit Sub
End If
'STR_SQL:生成下面的SQL语言中的字段例表
Str_txt = ""
If List3.ListCount <> 0 Then
For i = 0 To List3.ListCount - 1
If i = 0 Then
STR_SQL = List3.List(i)
Else
STR_SQL = STR_SQL & "," & List3.List(i)
End If
Next i
End If
If BB_type = "报表" Then
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = FB_table2
Adodc1.Refresh
Else
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select " & STR_SQL & " from " & FB_table2
Adodc1.Refresh
End If
'MsgBox Adodc1.RecordSource
Field_COUNT = Adodc1.Recordset.Fields.Count
ReDim w_field(Field_COUNT)
If Adodc1.Recordset.RecordCount <> 0 Then
Rec_Count = Adodc1.Recordset.RecordCount
Page_Count = Round(Rec_Count / Text2)
List1.Clear
'STR_TXT:报表中的栏目字段内容(下面生成)
Str_txt = ""
For ii = 0 To Adodc1.Recordset.Fields.Count - 1
str_Field = CStr(Adodc1.Recordset.Fields(ii).Name)
'w_field(ii) = IIf(Adodc1.Recordset.Fields(ii).DefinedSize <= LenB(StrConv(str_Field, vbFromUnicode)), IIf(LenB(StrConv(str_Field, vbFromUnicode)) <= 8, 10, LenB(StrConv(str_Field, vbFromUnicode)) + 2), IIf(Adodc1.Recordset.Fields(ii).DefinedSize <= 8, 10, Adodc1.Recordset.Fields(ii).DefinedSize + 2))
w_field(ii) = IIf(Adodc1.Recordset.Fields(ii).DefinedSize <= LenB(StrConv(str_Field, vbFromUnicode)), 10, IIf(Adodc1.Recordset.Fields(ii).Type = adCurrency, 10, Adodc1.Recordset.Fields(ii).DefinedSize))
'连接字段内容成一行
Str_txt = Str_txt & str_Field & Space(w_field(ii) - LenB(StrConv(str_Field, vbFromUnicode)))
Next
List1.AddItem Str_txt
'----------------------全部记录内容--------------------------
str_Field = ""
Adodc1.Recordset.MoveFirst
While Not Adodc1.Recordset.EOF
'------------当条记录------------
Str_txt = ""
For ii = 0 To Adodc1.Recordset.Fields.Count - 1
If IsNull(Adodc1.Recordset.Fields(ii)) Then
str_Field = ""
Else
If Adodc1.Recordset.Fields(ii).Type = adCurrency Then
If Adodc1.Recordset.Fields(ii) >= 0 Then
str_Field = Trim(CStr(Format(Adodc1.Recordset.Fields(ii), " .00")))
Else
str_Field = "-" & Trim(CStr(Format(Abs(Adodc1.Recordset.Fields(ii)), " .00")))
End If
str_Field = Space(9 - Len(Trim(str_Field))) & str_Field
Else
str_Field = Trim(CStr(Adodc1.Recordset.Fields(ii)))
End If
End If
If w_field(ii) > LenB(StrConv(str_Field, vbFromUnicode)) Then
W_space = w_field(ii) - LenB(StrConv(str_Field, vbFromUnicode))
Else
W_space = 0
End If
'连接记录成一行
Str_txt = Str_txt & str_Field & Space(W_space)
Next
List1.AddItem Str_txt
'------------当条记录结束------------
Adodc1.Recordset.MoveNext
Wend
Adodc1.Recordset.Close
List1.AddItem "======================记录数:" & CStr(List1.ListCount - 1) & "==================================================================================================================================================="
'----------------------全部记录内容--------------------------结束
rPnt = 1
' initialize preview engine
TempInit
' page 1
' start with a new page
l = 1
ll = 1
i = 1
Page_Count = 1
If CInt(Me.Text2.Text) > List1.ListCount Then
Me.Text2.Text = List1.ListCount
End If
While i <= List1.ListCount - 1
PrintHeader DWMC & "管理系统", CStr(Page_Count), 0
PrintInCen Int((Paper_W - 3) / 2), 1.5, Text1.Text, "黑体", 14, True, 0
PrintInLef 0.5, 2.5, List1.List(0), "宋体", 10, False, 0
PrintBox 0.5, 2.8, Paper_W - 1, 2.81, 0
For l = 1 To CInt(Me.Text2.Text)
PrintInLef 0.5, 2.5 + (0.5 * l), List1.List(i), "宋体", 10, False, 0
If Not Option1 Then
PrintBox 0.5, 2.8 + (0.5 * l), Paper_W - 1, 2.81 + (0.5 * l), 0
End If
i = i + 1
Next l
Page_Count = Page_Count + 1
PrintFooter "奥凯软件", " ", 0
Wend
End If
End Sub
Private Sub Command2_Click()
If List2.ListIndex <> -1 Then
List3.AddItem List2.List(List2.ListIndex)
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
If List3.ListCount <> 0 Then
If List3.ListIndex <> -1 Then
List3.RemoveItem List3.ListIndex
End If
End If
End Sub
Private Sub Command5_Click()
Dim Str1 As String
Dim i As Long
If List3.ListCount = 0 Then
MsgBox "请注意:您未选择打印所需栏目,请您选择后再继续!", 48, "提示"
Exit Sub
End If
Adodc2.ConnectionString = My_PROVIDER
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from 报表栏目表 where 报表名称 like '" & BB_title & "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
If Adodc2.Recordset.RecordCount >= List3.ListCount Then
Adodc2.Recordset.MoveFirst
i = 0
While Not Adodc2.Recordset.EOF
If i < List3.ListCount Then
Adodc2.Recordset.Fields("报表名称") = BB_title
Adodc2.Recordset.Fields("报表栏目") = List3.List(i)
Adodc2.Recordset.Update
Else
Adodc2.Recordset.Fields("报表名称") = ""
Adodc2.Recordset.Fields("报表栏目") = ""
Adodc2.Recordset.Update
End If
i = i + 1
Adodc2.Recordset.MoveNext
Wend
Else
Adodc2.Recordset.MoveFirst
i = 1
While i <= List3.ListCount
If i <= Adodc2.Recordset.RecordCount Then
Adodc2.Recordset.Fields("报表名称") = BB_title
Adodc2.Recordset.Fields("报表栏目") = List3.List(i - 1)
Adodc2.Recordset.MoveNext
Else
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("报表名称") = BB_title
Adodc2.Recordset.Fields("报表栏目") = List3.List(i - 1)
End If
i = i + 1
Wend
Adodc2.Recordset.Update
End If
Else
For i = 0 To List3.ListCount - 1
Adodc2.Recordset.AddNew
Adodc2.Recordset.Fields("报表名称") = BB_title
Adodc2.Recordset.Fields("报表栏目") = List3.List(i)
Next
Adodc2.Recordset.Update
End If
Adodc2.Recordset.Close
MsgBox BB_title & " 栏目已保存!", 64, "提示"
End Sub
Private Sub Form_Load()
Dim i As Long
Dim Str1 As Variant
If BB_type = "报表" Then
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = FB_table2
Adodc1.Refresh
Else
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from " & FB_table2
Adodc1.Refresh
End If
For i = 0 To Adodc1.Recordset.Fields.Count - 1
List2.AddItem Adodc1.Recordset.Fields(i).Name
If BB_type = "报表" Then
List3.AddItem Adodc1.Recordset.Fields(i).Name
End If
Next i
STR_SQL = ""
Text1.Text = BB_title
If Option3.Value Then
Paper_W = 21
Paper_H = 29.7
End If
If Option4.Value Then
Paper_W = 29.7
Paper_H = 38
End If
If Option5.Value Then
Paper_W = 15
Paper_H = 21
End If
If Option6.Value Then
Paper_W = 21
Paper_H = 29.7
End If
If Option8.Value Then
PAPERW = Paper_W
PAPERH = Paper_H
End If
If Option7.Value Then
PAPERW = Paper_H
PAPERH = Paper_W
End If
Adodc2.ConnectionString = My_PROVIDER
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from 报表栏目表 where 报表名称 like '" & BB_title & "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
' MsgBox BB_title & " 栏目已存在,直接调用!", 64, "提示"
i = 0
List3.Clear
While Not Adodc2.Recordset.EOF
List3.AddItem Adodc2.Recordset.Fields("报表栏目")
Adodc2.Recordset.MoveNext
Wend
End If
Adodc2.Recordset.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
TempInit
End Sub
Private Sub Option3_Click()
Paper_W = 21
Paper_H = 29.7
PAPERW = 21
PAPERH = 29.7
End Sub
Private Sub Option4_Click()
Paper_W = Int(15 * 2.54)
Paper_H = Int(11 * 2.54)
PAPERW = Int(15 * 2.54)
PAPERH = Int(11 * 2.54)
End Sub
Private Sub Option5_Click()
Paper_W = Int(9 * 2.54)
Paper_H = Int(11 * 2.54)
PAPERW = Int(9 * 2.54)
PAPERH = Int(11 * 2.54)
End Sub
Private Sub Option6_Click()
Paper_W = 21
Paper_H = 29.7
PAPERW = 21
PAPERH = 29.7
End Sub
Private Sub Option7_Click()
PAPERW = Paper_H
PAPERH = Paper_W
End Sub
Private Sub Option8_Click()
PAPERW = Paper_W
PAPERH = Paper_H
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -