⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file2.frm

📁 演示了由MDB数据库生成HTML表格文件的演示效果。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   BackColor       =   &H00C0C0C0&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "表格设置"
   ClientHeight    =   5235
   ClientLeft      =   30
   ClientTop       =   330
   ClientWidth     =   6360
   Icon            =   "file2.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5235
   ScaleWidth      =   6360
   StartUpPosition =   3  'Windows Default
   Begin VB.CheckBox option1 
      Caption         =   "是否将此列设置为超链接"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   372
      Left            =   3240
      TabIndex        =   9
      Top             =   2160
      Width           =   3015
   End
   Begin VB.TextBox Text3 
      Height          =   372
      Left            =   3360
      TabIndex        =   7
      Top             =   3720
      Width           =   2175
   End
   Begin VB.TextBox Text2 
      ForeColor       =   &H00FF0000&
      Height          =   372
      Left            =   480
      TabIndex        =   5
      Text            =   "HTML表格"
      Top             =   3720
      Width           =   2052
   End
   Begin VB.CommandButton ok 
      Caption         =   "确定"
      Height          =   495
      Left            =   2400
      TabIndex        =   4
      Top             =   4440
      Width           =   1335
   End
   Begin VB.TextBox Text1 
      Height          =   372
      Left            =   3240
      TabIndex        =   2
      Top             =   1080
      Width           =   2895
   End
   Begin VB.ListBox List1 
      ForeColor       =   &H00FF00FF&
      Height          =   2085
      ItemData        =   "file2.frx":000C
      Left            =   240
      List            =   "file2.frx":000E
      Style           =   1  'Checkbox
      TabIndex        =   0
      Top             =   1080
      Width           =   2652
   End
   Begin VB.Label Label4 
      Caption         =   "每个表格的行数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   3480
      TabIndex        =   8
      Top             =   3360
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "表格标题"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   840
      TabIndex        =   6
      Top             =   3360
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "编辑列标题"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   375
      Left            =   3840
      TabIndex        =   3
      Top             =   360
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "选择列"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   13.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   375
      Left            =   960
      TabIndex        =   1
      Top             =   360
      Width           =   1215
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As Recordset, ll() As Boolean
Private Sub Form_Load()
Dim i As Integer, dd As String
On Error GoTo er
Set rs = Form1.rs
ReDim ll(rs.Fields.Count - 1)
List1.Clear
rs.MoveFirst
For i = 0 To rs.Fields.Count - 1
List1.AddItem rs.Fields(i).Name
List1.Selected(i) = True
dd = List1.List(i)
If rs.Fields(dd).Type = 10 Then
If LCase(Left(rs.Fields(dd).Value, 7)) = "http://" Then
ll(i) = True
Else
ll(i) = False
End If
End If
Next
Text3 = Form1.nn
Exit Sub
er:
MsgBox "出现错误!"
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Close #1
End Sub

Private Sub List1_Click()
Dim dd As String
If List1.Selected(List1.ListIndex) Then
dd = List1.List(List1.ListIndex)
Text1 = dd
Text1.Enabled = True
option1.Enabled = True
option1.Value = IIf(ll(List1.ListIndex), vbChecked, Unchecked)
Else
Text1 = List1.List(List1.ListIndex)
option1.Enabled = False
Text1.Enabled = False
End If
End Sub

Private Sub ok_Click()
On Error GoTo cc
Dim n As Long
If List1.SelCount > 0 Then
Dim htmls As String
Print #1, "<html>"
Print #1, "<head>"
Print #1, "<title>" & Text2 & "</title>"
Print #1, "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
Print #1, "</head>"
Print #1, "<body>"
Print #1, "<p> 共有" & CStr(Form1.nn) & "条记录!!!"
rs.MoveFirst
n = 0
While rs.EOF = False
Print #1, "<table border=1 align=center>"
Print #1, "<caption>" & Text2 & "</caption>"
Fsum = List1.ListCount - 1
For i = 0 To Fsum
If List1.Selected(i) Then
Print #1, "<th>" & List1.List(i) & "</th>"
End If
Next
Dim bb As Long, ca As String, values As String
bb = 1
For n = 1 To Val(Text3)
Print #1, "<tr>"
For i = 0 To Fsum
If List1.Selected(i) Then
If ll(i) Then
values = "<td><a href='" & rs.Fields(i).Value & "'>" & rs.Fields(i).Value
values = values & "</a></td>"
Else
values = "<td>" & rs.Fields(i).Value & "</td>"
End If
Print #1, values
End If
Next i
rs.MoveNext
If rs.EOF Then
Exit For
End If
Next n
Print #1, "</table>"
Wend
Print #1, "</body>"
Print #1, "</html>"
End If
Unload Me
Exit Sub
cc:
MsgBox "出现错误,请返回!"

Unload Me
End Sub

Private Sub Option1_Click()
ll(List1.ListIndex) = (option1.Value = vbChecked)
End Sub

Private Sub Text1_Change()
Dim lens As Integer
List1.List(List1.ListIndex) = Text1
lens = Len(Trim(CStr(Text2)))
If lens > 50 Then Text1 = Left(CStr(Text2), 50)
End Sub

Private Sub Text2_Change()
If Len(Trim(CStr(Text2))) > 30 Then Text2 = Left(CStr(Text2), 30)
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub

Private Sub Text3_LostFocus()
If Val(Text3) < 1 Then Text3 = 1
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -