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

📄 form1.frm

📁 可以识别回车键的批量insertSQLdb里的小软件,把DB名改为你的,sql语句 也改也可以用在你们那里了
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   4680
   FillColor       =   &H00E0E0E0&
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   MouseIcon       =   "Form1.frx":08CA
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text5 
      Height          =   1455
      Left            =   2160
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   6
      Top             =   600
      Width           =   2055
   End
   Begin VB.TextBox Text4 
      Height          =   270
      Left            =   720
      TabIndex        =   5
      Text            =   "EJJKKLLGMMSSR01234HI"
      Top             =   1680
      Width           =   855
   End
   Begin VB.TextBox Text3 
      Height          =   270
      Left            =   720
      TabIndex        =   4
      Top             =   1200
      Width           =   855
   End
   Begin VB.TextBox Text2 
      Height          =   270
      Left            =   720
      TabIndex        =   3
      Text            =   "MZC600"
      Top             =   720
      Width           =   855
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Left            =   720
      TabIndex        =   2
      Text            =   "B1"
      Top             =   240
      Width           =   855
   End
   Begin VB.CommandButton Command2 
      Caption         =   "EXIT"
      Height          =   255
      Left            =   3000
      TabIndex        =   1
      Top             =   2880
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Insert"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   2880
      Width           =   975
   End
   Begin VB.Label Label7 
      Height          =   255
      Left            =   2880
      TabIndex        =   13
      Top             =   240
      Width           =   1455
   End
   Begin VB.Label Label6 
      Height          =   495
      Left            =   240
      TabIndex        =   12
      Top             =   2280
      Width           =   4095
   End
   Begin VB.Label Label5 
      Caption         =   "OP_ID"
      Height          =   255
      Left            =   2160
      TabIndex        =   11
      Top             =   240
      Width           =   735
   End
   Begin VB.Label Label4 
      Caption         =   "RIGHT"
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   1680
      Width           =   495
   End
   Begin VB.Label Label3 
      Caption         =   "REMARK"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   1200
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "DEPT"
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   720
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "Line"
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   240
      Width           =   495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private adocn As ADODB.Connection
Private Sub Command1_Click()
Dim sql As String
Dim rs As New ADODB.Recordset
Label6.BackColor = &H8000000F
Label6.Caption = ""
Text = Text5.Text
ch = Chr(13)

Do

en = InStr(Text, ch)
sp = InStr(Text, " ")

If sp Then '当有空格
    Label6.Caption = "有多余的空格!"
    Label6.BackColor = vbRed
    Text5.SetFocus
    Text5.SelStart = sp - 1
    Text5.SelLength = 1
    Exit Do
End If

If en Then '当有回车键时


    tex = Left(Text, en - 1)
    Text = Mid(Text, en + 2)
  
    
 Else
    
        
    tex = Text
    
   
End If

Select Case True

 Case Len(tex) = 0
       If Text = "" Then
              Label6.Caption = "OK!"
              Label6.BackColor = &HFFFFC0
              Exit Sub
       End If
         Label6.BackColor = vbRed
         Label6.Caption = "输入的有多余的行..."
         Exit Sub
         
 Case Len(tex) < 8 Or Len(tex) > 9
         Label6.BackColor = vbRed
         Label6.Caption = "输入的工号位数不正确"
         Text5.SetFocus
         Text5.SelStart = InStr(Text5.Text, tex) - 1
         Text5.SelLength = Len(tex)
         Exit Sub
 
 
End Select

    



sql = "select * from op_dat where op_id='" & tex & "'"
rs.Open sql, adocn, adOpenDynamic
If rs.RecordCount >= 1 Then
    Label6.BackColor = vbRed
    Label6.Caption = tex & "--已经建立有了..."
    
    Text5.SetFocus
    Text5.SelStart = InStr(Text5.Text, tex) - 1
    Text5.SelLength = Len(tex)
  
    Exit Do
      
       
    Else
    
    
    sql = "insert into op_dat(op_id,line,name,dept,password,upd_time,remark,right) values ('" & tex & "','" & Text1.Text & "','" & tex & "','" & Text2.Text & "','" & tex & "','" & Format(Date, "yyyymmdd") & Format(Time, "hh:mm:ss") & "','" & Text3.Text & "','" & Text4.Text & "')"
    adocn.BeginTrans
    adocn.Execute sql
    adocn.CommitTrans
    a = 1
    
    c = c + a
    Label7.Caption = "建立了...(" & c & ")"
    
    rs.Close
    End If
    
If Text = tex Then
   
    Exit Do
    
End If

Text5.Text = Text

Loop




End Sub


Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()


pw = "atest"
use = "atest"
db = "box"
   

    Set adocn = New ADODB.Connection
    adocn.Provider = "MSDAORA"
    adocn = "DATA SOURCE=" & db & ";"
    With adocn
        .ConnectionTimeout = 10
        .CursorLocation = adUseClient
        .Open adocn, use, pw
    End With
    
End Sub

⌨️ 快捷键说明

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