📄 frmdraw.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmSpssDraw
BorderStyle = 1 'Fixed Single
Caption = "调用SPSS绘图"
ClientHeight = 9570
ClientLeft = 45
ClientTop = 330
ClientWidth = 7770
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 9570
ScaleWidth = 7770
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 5520
TabIndex = 18
Top = 8760
Width = 1215
End
Begin VB.CommandButton cmdDrawBar
Caption = "绘条形图"
Height = 375
Left = 1440
TabIndex = 11
Top = 8760
Width = 1215
End
Begin VB.Frame Frame1
Caption = "说明"
Height = 3855
Left = 360
TabIndex = 9
Top = 4320
Width = 1575
Begin VB.Label Label3
Caption = " 本程序首先打开一个扩展名为sav的数据文件,然后在该文件的变量列表中选取两个变量,利用SPSS作它们的条形图或散点图。"
Height = 3015
Left = 240
TabIndex = 10
Top = 360
Width = 1215
End
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 7200
Top = 720
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdOpen
Caption = "打开文件..."
Height = 375
Left = 6120
TabIndex = 8
Top = 240
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Left = 360
TabIndex = 7
Top = 240
Width = 5535
End
Begin VB.CommandButton cmdMove2
Caption = ">>"
Height = 375
Left = 3480
TabIndex = 6
Top = 2520
Width = 375
End
Begin VB.CommandButton cmdMove1
Caption = ">>"
Height = 420
Left = 3480
TabIndex = 5
Top = 1680
Width = 375
End
Begin VB.ListBox lstVarSecond
Height = 420
Left = 4200
TabIndex = 4
Top = 2520
Width = 2895
End
Begin VB.ListBox lstVarFirst
Height = 420
Left = 4200
TabIndex = 3
Top = 1680
Width = 2895
End
Begin VB.ListBox lstVarSource
Height = 2040
Left = 480
TabIndex = 2
Top = 1560
Width = 2655
End
Begin VB.PictureBox picSpssDraw
Height = 4335
Left = 2160
ScaleHeight = 4275
ScaleWidth = 5235
TabIndex = 1
Top = 4080
Width = 5295
Begin VB.Image imgDraw
Height = 4335
Left = 0
Stretch = -1 'True
Top = 0
Visible = 0 'False
Width = 5295
End
End
Begin VB.CommandButton cmdDrawScaPlot
Caption = "绘散点图"
Height = 375
Left = 3480
TabIndex = 0
Top = 8760
Width = 1215
End
Begin VB.Frame Frame2
Caption = "变量设置"
Height = 3015
Left = 240
TabIndex = 12
Top = 840
Width = 7215
Begin VB.CommandButton cmdYes
Caption = "确 定"
Height = 375
Left = 5640
TabIndex = 14
Top = 2400
Width = 1095
End
Begin VB.CommandButton cmdReset
Caption = "重 设"
Height = 375
Left = 4080
TabIndex = 13
Top = 2400
Width = 1095
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "变量二(纵轴)"
Height = 180
Left = 3960
TabIndex = 17
Top = 1320
Width = 1080
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "变量一(横轴)"
Height = 180
Left = 3960
TabIndex = 16
Top = 480
Width = 1080
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "源变量列表"
Height = 180
Left = 360
TabIndex = 15
Top = 360
Width = 900
End
End
End
Attribute VB_Name = "frmSpssDraw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const strFileAndVariablesFirst As String = "请先打开数据文件,选择要分析的变量,并单击“确定”按钮。"
Const strFileChanged As String = "数据文件已经改变,要生成当前数据的交互图请首先输入变量,并单击“确定”按钮。"
Const strFileNotOpenOrNull As String = "请打开数据文件,或者您打开的数据文件为空文件。"
Const strVariableFirst As String = "请输入要分析的变量。"
Const strVariableChanged As String = "变量已经改变,要生成当前变量数据的交互图请首先输入变量,并单击“确定”按钮。"
Const strVarNotEnough As String = "变量个数不够,至少需要两个变量。"
Dim objSpssApp As Object
Dim objOutputDoc As Object
Dim objSPSSInfo As Object
Dim objDataDoc As Object
Dim objDocuments As Object
Dim objOutputItems As Object
Dim objOutputItem As Object
Dim objIGraph As Object
Dim strListOfVars() As String
Dim strSelVar() As String
Dim strSelVar2() As String
Dim strNotSelVar() As String
Dim bolSelected() As Integer
Dim intArrayIndex() As Integer
Dim bolDrawOrNot As Boolean
Dim bolFileChanged As Boolean
Dim bolVariableChanged As Boolean
Dim strVarFirst As String
Dim strVarSecond As String
Dim intListCountSource As Integer
Dim intListCountFirst As Integer
Dim intListCountSecond As Integer
Private Sub cmdDrawBar_Click()
Dim strFilePath As String
'如果还没有作交互图,给出出错信息
If bolDrawOrNot = False Then
MsgBox (strFileAndVariablesFirst)
Exit Sub
End If
'如果数据文件已经改变,给出提示
If bolFileChanged = True Then
MsgBox (strFileChanged)
End If
'如果上次操作以后,分析变量经过改变,给出提示
If bolVariableChanged = True Then
MsgBox (strVariableChanged)
End If
strFilePath = App.Path & "\IGraph0.bmp"
With imgDraw
.Stretch = True
.Visible = True
.Picture = LoadPicture(strFilePath)
End With
End Sub
Private Sub cmdDrawScaPlot_Click()
Dim strFilePath As String
If bolDrawOrNot = False Then
MsgBox (strFileAndVariablesFirst)
Exit Sub
End If
If bolFileChanged = True Then
MsgBox (strFileChanged)
End If
If bolVariableChanged = True Then
MsgBox (strVariableChanged)
End If
strFilePath = App.Path & "\IGraph1.bmp"
With imgDraw
.Stretch = True
.Visible = True
.Picture = LoadPicture(strFilePath)
End With
End Sub
Private Sub cmdExit_Click()
'将SPSS应用设置为Nothing
Set objSpssApp = Nothing
'卸载窗体
Unload Me
End Sub
Private Sub cmdOpen_Click()
Dim strFileName1 As String
Dim strFileName2 As String
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
'设置过滤器
CommonDialog1.Filter = "(*.sav)|*.sav"
'指定缺省的过滤器
CommonDialog1.FilterIndex = 1
'显示“打开”对话框
CommonDialog1.ShowOpen
strFileName1 = Text1.Text
Text1.Text = ""
Text1.Text = Text1.Text & CommonDialog1.FileName
Text1.Enabled = False
strFileName2 = CommonDialog1.FileName
'根据列表框中的内容决定移动按钮上标题的显示方式
If (strFileName1 <> "") And (strFileName1 <> strFileName2) Then
bolFileChanged = True
cmdMove1.Enabled = True
cmdMove2.Enabled = True
cmdMove1.Caption = ">>"
cmdMove2.Caption = ">>"
End If
'在数据编辑器中打开指定文件名的数据,数据编辑器不可见
Set objDataDoc = objSpssApp.OpenDataDoc(CommonDialog1.FileName)
objDataDoc.Visible = False
'获取SPSS信息
Set objSPSSInfo = objSpssApp.SpssInfo
'获取变量
Call GetVariables
'如果数据文件中变量个数小于2,则不够分析
If lstVarSource.ListCount < 2 Then
MsgBox (strVarNotEnough)
Exit Sub
End If
ErrHandler:
'如果用户单击“取消”按钮
Exit Sub
End Sub
Sub GetVariables()
Dim intNumVariables As Integer
Dim intNumNotSel As Integer
Dim intI As Integer
'变量个数
intNumVariables = objSPSSInfo.NumVariables - 1
'定义动态数组
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -