📄 frmtongji1.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmtongji1
Caption = "Form6"
ClientHeight = 9180
ClientLeft = 60
ClientTop = 345
ClientWidth = 14535
LinkTopic = "Form6"
MDIChild = -1 'True
ScaleHeight = 9180
ScaleWidth = 14535
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 12360
Top = 3840
Visible = 0 'False
Width = 1335
_ExtentX = 2355
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = "he"
Password = "he"
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.Frame Frame10
Caption = "Frame10"
Height = 975
Left = 1800
TabIndex = 19
Top = 3600
Visible = 0 'False
Width = 10335
Begin VB.CommandButton Command2
Caption = "打印"
Height = 375
Left = 8160
TabIndex = 25
Top = 360
Visible = 0 'False
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "查询"
Height = 375
Left = 6360
TabIndex = 24
Top = 360
Visible = 0 'False
Width = 1095
End
Begin VB.ComboBox Combo2
Height = 300
Left = 4560
TabIndex = 23
Top = 360
Visible = 0 'False
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1440
TabIndex = 21
Top = 360
Visible = 0 'False
Width = 1335
End
Begin VB.Label Label2
Caption = "性别"
Height = 375
Left = 3480
TabIndex = 22
Top = 360
Visible = 0 'False
Width = 735
End
Begin VB.Label Label1
Caption = "年龄段"
Height = 375
Left = 360
TabIndex = 20
Top = 360
Visible = 0 'False
Width = 735
End
End
Begin VB.Frame Frame9
Height = 855
Left = 9840
TabIndex = 17
Top = 2160
Width = 4455
Begin VB.OptionButton Option9
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 18
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame8
Height = 855
Left = 5160
TabIndex = 15
Top = 2160
Width = 4455
Begin VB.OptionButton Option8
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 16
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame7
Height = 855
Left = 480
TabIndex = 13
Top = 2160
Width = 4455
Begin VB.OptionButton Option7
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 14
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame6
Height = 855
Left = 9840
TabIndex = 11
Top = 1200
Width = 4455
Begin VB.OptionButton Option6
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 12
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame5
Height = 855
Left = 5160
TabIndex = 9
Top = 1200
Width = 4455
Begin VB.OptionButton Option5
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 10
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame4
Height = 855
Left = 480
TabIndex = 7
Top = 1200
Width = 4455
Begin VB.OptionButton Option4
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 8
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame3
Height = 855
Left = 9840
TabIndex = 5
Top = 240
Width = 4455
Begin VB.OptionButton Option3
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 6
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame2
Height = 855
Left = 5160
TabIndex = 3
Top = 240
Width = 4455
Begin VB.OptionButton Option2
Caption = "Option1"
Height = 375
Left = 120
TabIndex = 4
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame1
Height = 855
Left = 480
TabIndex = 1
Top = 240
Width = 4455
Begin VB.OptionButton Option1
Caption = "统计某系某年龄段或某性别的学生总数"
Height = 375
Left = 120
TabIndex = 2
Top = 240
Width = 4215
End
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSF1
Height = 3255
Left = 480
TabIndex = 0
Top = 5040
Width = 13695
_ExtentX = 24156
_ExtentY = 5741
_Version = 393216
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
Attribute VB_Name = "frmtongji1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public printstr As String
Public Sub tongjishowtitle()
Dim i As Integer
MSF1.Clear
With MSF1
.Cols = 2
.TextMatrix(0, 1) = "总数"
.ColWidth(0) = 200
.FixedRows = 1
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Public Sub tongjishowdata()
MSF1.Clear
Dim j As Integer
Dim i As Integer
msql = ql()
Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = msql
Adodc1.Refresh
If Adodc1.Recordset.EOF = False Then
Adodc1.Recordset.MoveFirst
With MSF1
.Rows = 50
.Row = 1
Do While Not Adodc1.Recordset.EOF
.Rows = .Rows + 1
For i = 1 To Adodc1.Recordset.Fields.Count
.TextMatrix(.Row, i) = Adodc1.Recordset.Fields(i - 1)
Next i
.Row = .Row + 1
Adodc1.Recordset.MoveNext
Loop
End With
Else
If tongjifind = True Then
MsgBox "对不起,没有此课程的记录!", vbOKOnly, "查询"
frmtongji1.ZOrder 0
End If
End If
End Sub
Private Sub Form_Activate()
If tongjifind = True Then
tongji1.ZOrder 0
End If
If tongjifind = True Then
Exit Sub
ElseIf tongjimodi = True Then
tongjishowdata
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If jibenfind = True Then
jibenfind = False
frmjiben3.Text1(0).SetFocus
End If
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" And Combo2.Text = "" Then
MsgBox "请至少选择一个条件", vbExclamation + vbOKOnly, "警告"
Combo1.SetFocus
Exit Sub
End If
If Combo1.Text = "20岁以下" And Combo2.Text = "" Then
str = "select count(*) from student where student.age<20"
End If
If Combo1.Text = "20岁-25岁之间 " And Combo2.Text = "" Then
str = "select count(*) from student where student.age between 20 and 25"
End If
If Combo1.Text = "25岁以上" And Combo2.Text = "" Then
str = "select count(*) from student where student.age>25"
End If
If Combo1.Text = "20岁以下" And Combo2.Text = "男" Then
str = "select count(*) from student where student.age<20 and student.sex='man'"
End If
If Combo1.Text = "20岁以下" And Combo2.Text = "女" Then
str = "select count(*) from student where student.age<20 and student.sex='woman'"
End If
If Combo1.Text = "20岁-25岁之间" And Combo2.Text = "男" Then
str = "select count(*) from student select count(*) from student where student.age between 20 and 25 student.sex='man'"
End If
If Combo1.Text = "20岁-25岁之间" And Combo2.Text = "女" Then
str = "select count(*) from student where student.age between 20 and 25 student.sex='woman'"
End If
If Combo1.Text = "" And Combo2.Text = "男" Then
str = "select count(*) from student where student.sex='man'"
End If
If Combo1.Text = "" And Combo2.Text = "女" Then
str = "select count(*) from student where student.sex='woman'"
End If
Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
sql = str
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = sql
Adodc1.Refresh
If Adodc1.Recordset.EOF = True Then
MsgBox "没有符合条件的记录!", vbInformation + vbOKOnly, "查询"
Combo1.SetFocus
Exit Sub
End If
msql = "select count(*) from student" & str
printstr = msql
tongjifind = True
frmtongji1.tongjishowtitle
frmtongji1.tongjishowdata
End Sub
Private Sub Command2_Click()
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
MsgBox "没有当前记录!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If DataEnv1.rsCommand5.State = adStateOpen Then
DataEnv1.rsCommand5.Close
End If
DataEnv1.rsCommand5.Open (select count(*) from student) 'printstr
If DataEnv1.rsCommand5.EOF = True Then
MsgBox "没有当前记录!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
DataReportcount.Show 1
End Sub
Private Sub Form_Load()
With Combo1
.AddItem "20岁以下"
.AddItem "20岁-25岁之间"
.AddItem "25岁以上"
End With
With Combo2
.AddItem "男"
.AddItem "女"
End With
End Sub
Private Sub Option1_Click()
Label1.Visible = True
Label2.Visible = True
Combo1.Visible = True
Combo2.Visible = True
Command1.Visible = True
Command2.Visible = True
Frame10.Visible = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -