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

📄 frmsql.frm

📁 一个水情自动测报系统的接收例程
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form FrmSql 
   Caption         =   "SQL语句"
   ClientHeight    =   4572
   ClientLeft      =   132
   ClientTop       =   732
   ClientWidth     =   6468
   Icon            =   "frmSql.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   4572
   ScaleWidth      =   6468
   StartUpPosition =   3  '窗口缺省
   WindowState     =   2  'Maximized
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   5880
      Top             =   4080
      _ExtentX        =   677
      _ExtentY        =   677
      _Version        =   393216
   End
   Begin ComctlLib.TreeView TreeView1 
      Height          =   7572
      Left            =   8400
      TabIndex        =   5
      Top             =   120
      Width           =   3732
      _ExtentX        =   6583
      _ExtentY        =   13356
      _Version        =   327682
      LabelEdit       =   1
      LineStyle       =   1
      Style           =   7
      BorderStyle     =   1
      Appearance      =   1
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.8
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   2772
      Left            =   120
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   4
      Top             =   4920
      Width           =   8172
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出"
      Height          =   372
      Left            =   2400
      TabIndex        =   3
      Top             =   8040
      Width           =   972
   End
   Begin VB.CommandButton Command2 
      Caption         =   "清除"
      Height          =   372
      Left            =   1320
      TabIndex        =   2
      Top             =   8040
      Width           =   972
   End
   Begin VB.CommandButton Command1 
      Caption         =   "执行"
      Height          =   372
      Left            =   240
      TabIndex        =   1
      Top             =   8040
      Width           =   972
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.8
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4452
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   360
      Width           =   8172
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Height          =   180
      Left            =   240
      TabIndex        =   6
      Top             =   0
      Width           =   96
   End
   Begin VB.Menu F 
      Caption         =   "文件"
      Begin VB.Menu F1 
         Caption         =   "打开"
      End
      Begin VB.Menu F2 
         Caption         =   "保存"
      End
      Begin VB.Menu F3 
         Caption         =   "另存"
      End
   End
End
Attribute VB_Name = "FrmSql"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const MLJ = "SELECT UPDATE INSERT INTO FROM  WHERE AND OR GROUP ORDER BY ASC DESC HAVING ( ) SET CREATE TABLE VIEW INDEX DROP ALTER NULL CHAR INTEGER DATETIME FLOAT ADD DISTINCT  #  UNIQUE ON DELETE = <> > < . *  AS COUNT SUM AVG MAX MIN LIKE FORMAT IS IN EXISTS UNION VALUES  "
Private Sub Command1_Click()
Dim SQL_ST As String
Dim msg, style, title, response
SQL_ST = Me.Text1.Text

  On Error GoTo AddErr

msg = "您写的SQL语句是'" & SQL_ST & "'" ' 定义信息。
style = vbYesNo + vbDefaultButton2 + vbApplicationModal + vbExclamation
title = "请您确认是否执行?"  ' 定义标题。

response = MsgBox(msg, style, title)
If response = vbYes Then  ' 用户按下“是”

If InStr(StrConv(SQL_ST, 2), "select") <> 0 Then
Dim a As New frmdata
sql_string = SQL_ST
frmdata_caption = SQL_ST
a.Show

Else
DB1.Execute SQL_ST
End If

End If

  Exit Sub
AddErr:
  MsgBox Err.Description
End Sub

Private Sub Command2_Click()
Me.Text1.Text = ""
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub F1_Click()
Dim dc As String
Dim s1, s2 As String

On Error GoTo ErrHandler2
CommonDialog1.CancelError = True
CommonDialog1.Filter = "*.sql"
CommonDialog1.FilterIndex = 2
CommonDialog1.FileName = "*.sql"
CommonDialog1.ShowOpen

If (CommonDialog1.FileName <> "" And CommonDialog1.FileName <> "*.sql") Then
dc = Right(CommonDialog1.FileName, 3)
If dc = "sql" Then

Me.Label1.Caption = CommonDialog1.FileName
Open CommonDialog1.FileName For Input As #1
Do Until EOF(1)
Line Input #1, s1
s2 = s2 + s1 + Chr(13) + Chr(10)
Loop
Close #1

Text1.Text = s2
End If
End If

Exit Sub

ErrHandler2:
 '用户按了“取消”按钮
Exit Sub
End Sub

Private Sub F2_Click()
If Me.Label1.Caption <> "" Then
Open Me.Label1.Caption For Output As #1  ' 打开输出文件。
Print #1, Me.Text1.Text
Close #1
Else
F3_Click
End If
End Sub

Private Sub F3_Click()
On Error GoTo ErrHandler1

CommonDialog1.CancelError = True
CommonDialog1.Filter = "*.sql"
CommonDialog1.FilterIndex = 2
CommonDialog1.FileName = "*.sql"
CommonDialog1.ShowSave

If CommonDialog1.FileName <> "*.sql" Then
If InStr(CommonDialog1.FileName, ".sql") <> 0 Then
Open CommonDialog1.FileName For Output As #1 ' 打开输出文件
Me.Label1.Caption = CommonDialog1.FileName
Else
Open CommonDialog1.FileName & ".sql" For Output As #1 ' 打开输出文件
Me.Label1.Caption = CommonDialog1.FileName & ".sql"
End If
Print #1, Me.Text1.Text
Close #1
End If

ErrHandler1:
 '用户按了“取消”按钮
End Sub

Private Sub Form_Load()
Dim nodX As Node
Me.Text2.Text = MLJ


     Set nodX = TreeView1.Nodes.Add(, , "Root", "接收设置")
         nodX.Key = "1 node"
         nodX.Text = "接收设置"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "11 node"
         nodX.Text = "站号(int)"
         
    Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "12 node"
         nodX.Text = "站名(text)"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "13 node"
         nodX.Text = "雨量(bit)"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "14 node"
         nodX.Text = "水位(bit)"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "15 node"
         nodX.Text = "电压(bit)"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "16 node"
         nodX.Text = "字节类型(int)"
         
     Set nodX = TreeView1.Nodes.Add("1 node", tvwChild)
         nodX.Key = "17 node"
         nodX.Text = "设备号(int)"
         
         
     Set nodX = TreeView1.Nodes.Add(, , "Root", "原始数据")
         nodX.Key = "2 node"
         nodX.Text = "原始数据"
         
     Set nodX = TreeView1.Nodes.Add("2 node", tvwChild)
         nodX.Key = "21 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("2 node", tvwChild)
         nodX.Key = "22 node"
         nodX.Text = "数值(Single)"
         
     Set nodX = TreeView1.Nodes.Add("2 node", tvwChild)
         nodX.Key = "23 node"
         nodX.Text = "时间(datetime)"
         
     Set nodX = TreeView1.Nodes.Add("2 node", tvwChild)
         nodX.Key = "24 node"
         nodX.Text = "物理量(text)"
         
         
     Set nodX = TreeView1.Nodes.Add(, , "Root", "雨量")
         nodX.Key = "3 node"
         nodX.Text = "雨量"
         
     Set nodX = TreeView1.Nodes.Add("3 node", tvwChild)
         nodX.Key = "31 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("3 node", tvwChild)
         nodX.Key = "32 node"
         nodX.Text = "雨量(Single)"
         
     Set nodX = TreeView1.Nodes.Add("3 node", tvwChild)
         nodX.Key = "33 node"
         nodX.Text = "时间(datetime)"




     Set nodX = TreeView1.Nodes.Add(, , "Root", "水位")
         nodX.Key = "4 node"
         nodX.Text = "水位"
         
     Set nodX = TreeView1.Nodes.Add("4 node", tvwChild)
         nodX.Key = "41 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("4 node", tvwChild)
         nodX.Key = "42 node"
         nodX.Text = "水位(Single)"
         
     Set nodX = TreeView1.Nodes.Add("4 node", tvwChild)
         nodX.Key = "43 node"
         nodX.Text = "时间(datetime)"
         

     Set nodX = TreeView1.Nodes.Add(, , "Root", "电压")
         nodX.Key = "5 node"
         nodX.Text = "电压"
         
     Set nodX = TreeView1.Nodes.Add("5 node", tvwChild)
         nodX.Key = "51 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("5 node", tvwChild)
         nodX.Key = "52 node"
         nodX.Text = "电压(Single)"
         
     Set nodX = TreeView1.Nodes.Add("5 node", tvwChild)
         nodX.Key = "53 node"
         nodX.Text = "时间(datetime)"
         

     Set nodX = TreeView1.Nodes.Add(, , "Root", "水位高程")
         nodX.Key = "6 node"
         nodX.Text = "水位高程"
         
     Set nodX = TreeView1.Nodes.Add("6 node", tvwChild)
         nodX.Key = "61 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("6 node", tvwChild)
         nodX.Key = "62 node"
         nodX.Text = "水位高程(Single)"

     Set nodX = TreeView1.Nodes.Add(, , "Root", "水位微调")
         nodX.Key = "7 node"
         nodX.Text = "水位微调"
         
     Set nodX = TreeView1.Nodes.Add("7 node", tvwChild)
         nodX.Key = "71 node"
         nodX.Text = "站号(int)"
         
     Set nodX = TreeView1.Nodes.Add("7 node", tvwChild)
         nodX.Key = "72 node"
         nodX.Text = "水位微调(int)"
         
     Set nodX = TreeView1.Nodes.Add(, , "Root", "雨量排除")
         nodX.Key = "8 node"
         nodX.Text = "雨量排除"
         
     Set nodX = TreeView1.Nodes.Add("8 node", tvwChild)
         nodX.Key = "81 node"
         nodX.Text = "雨量排除(Single)"
         
     Set nodX = TreeView1.Nodes.Add(, , "Root", "水位排除")
         nodX.Key = "9 node"
         nodX.Text = "水位排除"
         
     Set nodX = TreeView1.Nodes.Add("9 node", tvwChild)
         nodX.Key = "91 node"
         nodX.Text = "水位排除(int)"

     Set nodX = TreeView1.Nodes.Add(, , "Root", "电压排除")
         nodX.Key = "10 node"
         nodX.Text = "电压排除"
         
     Set nodX = TreeView1.Nodes.Add("10 node", tvwChild)
         nodX.Key = "101 node"
         nodX.Text = "电压排除(int)"
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As Node)
 If InStr(Node.Text, "(") <> 0 Then
    Clipboard.SetText Left(Node.Text, InStr(Node.Text, "(") - 1)
 Else
    Clipboard.SetText Node.Text
 End If
End Sub

⌨️ 快捷键说明

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