回复 2# vbc 的帖子
Option Explicit
Option Compare Binary
'¹¤¾ßÌáʾ
Const TOOLTIP1 = "н¨Êý¾Ý¿â"
Const TOOLTIP2 = "´ò¿ªÊý¾Ý¿â"
Const TOOLTIP3 = "¹Ø±ÕÊý¾Ý¿â"
Const TOOLTIP4 = "´«µÝÀàÐͼǼ¼¯"
Const TOOLTIP5 = "ÔÚд°ÌåÉÏʹÓà Data ¿Ø¼þ"
Const TOOLTIP6 = "ÔÚд°ÌåÉϲ»Ê¹Óà Data ¿Ø¼þ"
Const TOOLTIP7 = "ÔÚд°ÌåÉÏʹÓà DBGrid ¿Ø¼þ"
Const TOOLTIP8 = "¿ªÊ¼ÊÂÎñ"
Const TOOLTIP9 = "»Ø¹öµ±Ç°ÊÂÎñ"
Const TOOLTIP10 = "Ìá½»µ±Ç°ÊÂÎñ" '
'ÔÓÏî×Ö·û´®
Const MSG3 = "°´»Ø³µ¼ü¹Ø±Õ¡°¹ØÓÚ¡±¶Ô»°¿ò"
'Ô­ÎÄÓÐÎó
Const MSG4 = "ÊäÈëÐÂÊý¾Ý¿â²ÎÊý"
Const MSG5 = "ÊäÈë ODBCINST.INI ÎļþÖеÄÇý¶¯³ÌÐòÃû³Æ£º"
Const MSG6 = "Çý¶¯³ÌÐòÃû³Æ"
Const MSG7 = "±ØÐëÊ×Ïȹرգ¡"
Const MSG8 = "×¢Ò⣺ÍƼöʹÓø½¼Ó±í"
Const MSG9 = "Microsoft Access MDB (*.mdb)|*.mdb|ËùÓÐÎļþ (*.*)|*.*"
Const MSG10 = "´ò¿ªÒªÐÞ¸´µÄ Microsoft Access Êý¾Ý¿â"
Const MSG11 = "ÕýÔÚÐÞ¸´"
Const MSG12 = "´ò¿ªÐÞ¸´µÄÊý¾Ý¿âÂð£¿"
Const MSG13 = "ϵͳÊý¾Ý¿â|SYSTEM.MD?"
Const MSG14 = "Ñ¡Ôñ SYSTEM.MD? £¨Microsoft Access °²È«Îļþ£©"
Const MSG15 = "Óû§£º"
Const MSG16 = "ÒòΪ´íÎ󣬱ØÐë¹Ø±Õµ±Ç°Êý¾Ý¿â£¡"
Const MSG17 = "δÕÒµ½Óû§£¬ÊÔһϡ°ÊµÓóÌÐò/System MD?¡±£¡"
Const MSG18 = "µÇ¼³¬Ê±£¨Ã룩£º"
Const MSG19 = "ûÓдò¿ªµÄÊý¾Ý¿â"
Const MSG20 = "²éѯ³¬Ê±£¨Ã룩£º"
Const MSG21 = "ɾ³ý±íÂð£¿"
Const MSG22 = "ɾ³ý²éѯ¶¨ÒåÂð£¿"
Const MSG23 = "ɾ³ý×Ö¶ÎÂð£¿"
Const MSG24 = "ɾ³ýË÷ÒýÂð£¿"
Const MSG25 = "ɾ³ý±íÖÐËùÓмǼÂð£¿"
Const MSG26 = "ɾ³ýµÄÐУº"
Const MSG27 = "δÕÒµ½ SYSTEM.MD?£¬ÔÚ VB ÉèÖÃÖµÖмÓÈëÒ»¸öÂð£¿"
Const MSG28 = "Õâ¸öÇý¶¯³ÌÐò²»Ö§³ÖÊÂÎñ£¡"
Const MSG29 = "ËùÓиı佫±»¶ªÊ§£¬»Ø¹öÂð£¿"
Const MSG30 = "ÊôÐÔÊÇÖ»¶ÁµÄ£¡"
Const MSG31 = "¸Ãº¯ÊýÐèÒªÒ»¸ö»î¶¯µÄ¹¤³Ì£¡"
Const MSG37 = "ɾ³ý¼Ç¼Âð£¿"
'>>>>>>>>>>>>>>>>>>>>>>>>
Dim mHwnd As Long
Private Sub mnuUSystemDB_Click()
On Error Resume Next
Dim sTmp As String
Dim X As Integer
With dlgCMD1
.Filter = MSG13
.DialogTitle = MSG14
.FilterIndex = 1
.FileName = "SYSTEM.MDW"
.CancelError = True
.Flags = FileOpenConstants.cdlOFNHideReadOnly + FileOpenConstants.cdlOFNFileMustExist
End With
On Error Resume Next
dlgCMD1.ShowOpen
If Err = 32755 Then
'Óû§È¡ÏûÁË
Exit Sub
Else
sTmp = dlgCMD1.FileName
'±ØÐëÊÇÒ»¸öºÃµÄÎļþÃû
SaveSetting APP_CATEGORY & "\Analysis", "Engines", "SystemDB", sTmp
SaveSetting APP_CATEGORY, App.Title, "LoadSystemDB", "Yes"
End If
End Sub
Private Sub MDIForm_Load()
Dim X As Integer
Screen.MousePointer = vbHourglass
'¹¤¾ßÌáʾ
tlbToolBar.Buttons(1).ToolTipText = TOOLTIP1
tlbToolBar.Buttons(2).ToolTipText = TOOLTIP2
tlbToolBar.Buttons(3).ToolTipText = TOOLTIP3
mnuOptReadOnly.Checked = True
gnReadOnly = True
gnSelectRun = False
mnuDBNew.Enabled = False
mnuDBClose.Visible = False
mnuDBBar0.Visible = False
mnuEdit.Visible = False
mnuOperate.Visible = False
'È¡µÃ´°Ìå×ù±ê
X = Val(GetINIString("WindowState", "2"))
If X <> 1 Then
frmMDI.WindowState = X
Else
frmMDI.WindowState = 0
End If
If frmMDI.WindowState = 0 Then
frmMDI.Left = Val(GetINIString("WindowLeft", "0"))
frmMDI.Top = Val(GetINIString("WindowTop", "0"))
frmMDI.Width = Val(GetINIString("WindowWidth", "9135"))
frmMDI.Height = Val(GetINIString("WindowHeight", "6900"))
End If
'¿´ÊÇ·ñÓû§ÔÚÒÔÇ°»Ø´ð¡°Ìí¼Ó system.mda¡±Ê±Ëµ¡°²»¡±
If Len(GetINIString("LoadSystemDB", vbNullString)) = 0 Then
'µÚÒ»´Î£¬ËùÒÔÌáʾÈç¹ûûÓоÍÌí¼ÓËü
If MsgBox("Ìí¼Ó SYSTEM.MD? (Microsoft Access °²È«Îļþ) µ½ INI ÎļþÂð£¿", vbYesNo + vbQuestion) = vbYes Then
mnuUSystemDB_Click
Else
'´æ´¢ÐÅÏ¢£¬¾Í²»ÓÃÔÙÎÊÁË
SaveSetting APP_CATEGORY, App.Title, "LoadSystemDB", "No"
End If
End If
On Error GoTo MDILErr
'ÉèÖÃ DBEngine
DBEngine.IniPath = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\" & APP_CATEGORY & "\" & App.Title
DBEngine.DefaultUser = "admin"
DBEngine.DefaultPassword = vbNullString
'µÇ¼µ½ Jet
On Error Resume Next
Set gwsMainWS = DBEngine.CreateWorkspace("MainWS", "admin", vbNullString)
On Error GoTo MDILErr
'Ìí¼Ó¹¤×÷¿Õ¼äµ½¼¯ºÏÖУ¬Ôö¼ÓÆäÊýÁ¿
Workspaces.Append gwsMainWS
Me.Show
LoadINISettings
Screen.MousePointer = vbDefault
Exit Sub
MDILErr:
ShowError
End Sub
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
ShutDownAnalysis
If mHwnd <> 0 Then
'µ± VisData ´Ó VB µÄ¡°Íâ½Ó³ÌÐò¡±²Ëµ¥ÖмÓÔØʱÐèÒª
mHwnd = SetWindowLong(Me.hwnd, -8, GetDesktopWindow())
End If
End Sub
Private Sub mnuDBClose_Click()
Me.mnuOptPaint.Enabled = False 'ʹ»æÖƶԱÈͼ°´Å¥ÎÞЧ
mnuOptRelative.Enabled = False
CloseCurrentDB
End Sub
Private Sub mnuDBExit_Click()
Unload Me
End Sub
Private Sub mnuDBMRU_Click(Index As Integer)
On Error GoTo MRUErr
gsDBName = Mid(mnuDBMRU(Index).Caption, 4, Len(mnuDBMRU(Index).Caption))
gsDataType = mnuDBMRU(Index).Tag
OpenLocalDB 2
Me.mnuOptPaint.Enabled = True
Exit Sub
MRUErr:
ShowError
End Sub
Private Sub mnuDBNew_Click()
NewMDB dbVersion30
End Sub
Private Sub mnuDBOpen_Click()
'´ò¿ªÊý¾ÝÎļþ
gsDataType = gsMSACCESS
OpenLocalDB 1
Me.mnuOptPaint.Enabled = True
End Sub
Private Sub mnuDfilter_Click()
Dim frm As New frmFilter
frm.Show
End Sub
Private Sub mnuEdtDelete_Click()
On Error GoTo RFErr
If Not grstRecordset.EOF Then
If MsgBox(MSG37, vbYesNo + vbQuestion) = vbYes Then
grstRecordset.Delete
End If
End If
Exit Sub
RFErr:
ShowError
End Sub
Private Sub mnuEdtNumber_Click()
On Error GoTo NMbErr
Dim i As Integer
grstRecordset.MoveFirst
With grstRecordset.Fields(0)
For i = 1 To grstRecordset.RecordCount
grstRecordset.Edit
.Value = i
grstRecordset.Update
grstRecordset.MoveNext
Next i
End With
Exit Sub
NMbErr:
ShowError
End Sub
Private Sub mnuEdtEditer_Click()
On Error GoTo LoadErr
Dim str As String
Dim dbTemp As Database
str = gsDBName
CloseCurrentDB
Set dbTemp = gwsMainWS.OpenDatabase(str, False, gnReadOnly, vbNullString)
Set gdbCurrentDB = dbTemp
gsDBName = str
frmTblStruct.Show vbModal
Exit Sub
LoadErr:
ShowError
End Sub
Private Sub mnuHelpContents_Click()
Dim nRet As Integer
'Èç¹ûÕâ¸ö¹¤³ÌûÓаïÖúÎļþ£¬ÏÔʾÏûÏ¢¸øÓû§
'¿ÉÒÔÔÚ¡°¹¤³ÌÊôÐÔ¡±¶Ô»°¿òÖÐΪӦÓóÌÐòÉèÖðïÖúÎļþ
App.HelpFile = App.Path + "\" + "analysis.hlp"
If Len(App.HelpFile) = 0 Then
MsgBox "ÎÞ·¨ÏÔʾ°ïÖúĿ¼£¬¸Ã¹¤³ÌûÓÐÏà¹ØÁªµÄ°ïÖú¡£", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuHelpSearch_Click()
Dim nRet As Integer
App.HelpFile = App.Path + "\" + "analysis.hlp"
'Èç¹ûÕâ¸ö¹¤³ÌûÓаïÖúÎļþ£¬ÏÔʾÏûÏ¢¸øÓû§¿ÉÒÔÔÚ¡°¹¤³ÌÊôÐÔ¡±¶Ô»°¿òÖÐΪӦÓóÌÐòÉèÖðïÖúÎļþ
If Len(App.HelpFile) = 0 Then
MsgBox "ÎÞ·¨ÏÔʾ°ïÖúĿ¼£¬¸Ã¹¤³ÌûÓÐÏà¹ØÁªµÄ°ïÖú¡£", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuHlpAbout_Click()
frmAbout.Show 1
End Sub
Private Sub mnuOperStart_Click()
Dim frm As New frmOperation
If gnSelectRun Then frmSetRange.Show vbModal
frm.Show
End Sub
Private Sub mnuOptDeterminer_Click()
frmDeterminer.Show vbModal
End Sub
Private Sub mnuOptPaint_Click()
optPaint.Show 1
End Sub
Private Sub mnuOptReadOnly_Click()
If mnuOptReadOnly.Checked = True Then
mnuOptReadOnly.Checked = False
gnReadOnly = False
mnuDBNew.Enabled = True
tlbToolBar.Buttons("New").Enabled = True
mnuEdit.Enabled = True
Else
mnuOptReadOnly.Checked = True
gnReadOnly = True
mnuDBNew.Enabled = False
tlbToolBar.Buttons("New").Enabled = False
mnuEdit.Enabled = False
End If
End Sub
Private Sub mnuOptRelative_Click()
ksqt.Show
End Sub
Private Sub mnuOptSelectRun_Click()
If mnuOptSelectRun.Checked = True Then
mnuOptSelectRun.Checked = False
gnSelectRun = False
Else
mnuOptSelectRun.Checked = True
gnSelectRun = True
End If
End Sub
Private Sub mnuRC_Click()
mnuOperStart.Enabled = True
If relativeAlyasis = True Then
mnuOptRelative.Enabled = True
Else
mnuOptRelative.Enabled = False
End If
frmRateCalcu.Show
End Sub
Private Sub Timer1_Timer()
frmMDI.stsStatusBar.Panels(3).Text = Format$(Time, "
hh:mm:ss")
frmMDI.stsStatusBar.Panels(1).Text = "°æȨËùÓÐ(C) 1999-2000"
End Sub
Private Sub tlbToolBar_ButtonClick(ByVal Button As Control)
On Error GoTo tlbToolBar_ButtonClickErr
Select Case Button.Key
Case "New"
mnuDBNew_Click
Case "Open"
mnuDBOpen_Click
Me.mnuOptPaint.Enabled = True
Case "Close"
mnuDBClose_Click
Me.mnuOptPaint.Enabled = False 'ʹ»æÖƶԱÈͼ°´Å¥ÎÞЧ
Case "Edit"
mnuEdtEditer_Click
Case "Delete"
mnuEdtDelete_Click
Case "Number"
mnuEdtNumber_Click
End Select
Exit Sub
tlbToolBar_ButtonClickErr:
ShowError
End Sub