frmserver.frm

来自「VB 编写的"华成POS管理系统",代码全,没有进行测试,数据库全,有兴趣的朋友」· FRM 代码 · 共 204 行

FRM
204
字号
VERSION 5.00
Begin VB.Form frmServer 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "设置 SQL 服务器"
   ClientHeight    =   2715
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4560
   Icon            =   "frmServer.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   181
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   304
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin VB.TextBox Txtfield 
      Height          =   375
      Index           =   3
      Left            =   960
      TabIndex        =   9
      Text            =   "SuperMarketdb"
      Top             =   1680
      Width           =   2055
   End
   Begin VB.TextBox Txtfield 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Index           =   2
      Left            =   960
      PasswordChar    =   "*"
      TabIndex        =   8
      Top             =   1200
      Width           =   2055
   End
   Begin VB.TextBox Txtfield 
      Height          =   375
      Index           =   1
      Left            =   960
      TabIndex        =   7
      Top             =   720
      Width           =   2055
   End
   Begin VB.TextBox Txtfield 
      Height          =   375
      Index           =   0
      Left            =   960
      TabIndex        =   0
      Top             =   240
      Width           =   2055
   End
   Begin VB.Label Label5 
      BackStyle       =   0  'Transparent
      Caption         =   "Space.存储  Enter换行  Esc退出  "
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1320
      TabIndex        =   10
      Top             =   2280
      Width           =   5055
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "数据库:"
      Height          =   180
      Left            =   240
      TabIndex        =   6
      Top             =   1755
      Width           =   720
   End
   Begin VB.Label lbPW 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "(密码已隐藏)"
      Height          =   180
      Left            =   3240
      TabIndex        =   5
      Top             =   1275
      Visible         =   0   'False
      Width           =   1080
   End
   Begin VB.Label lbCT 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "测试连接中..."
      ForeColor       =   &H00FF0000&
      Height          =   180
      Left            =   240
      TabIndex        =   4
      Top             =   2295
      Visible         =   0   'False
      Width           =   1170
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密  码:"
      Height          =   180
      Left            =   240
      TabIndex        =   3
      Top             =   1275
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "服务器:"
      Height          =   180
      Left            =   240
      TabIndex        =   2
      Top             =   315
      Width           =   720
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   795
      Width           =   720
   End
End
Attribute VB_Name = "frmServer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 27
Unload Me
Case 119

Case 46
Form2.Show 1
Case 32

On Error GoTo aaaa
    If txtfield(0).Text = "" Then
        MsgBox "必须填写 SQL 服务器名称或 IP 地址。", vbInformation
        txtfield(0).SetFocus
        Exit Sub
    End If
    If txtfield(1).Text = "" Then
        MsgBox "必须填写 SQL 服务器的用户名。", vbInformation
        txtfield(1).SetFocus
        Exit Sub
    End If
    If txtfield(3).Text = "" Then
        MsgBox "必须填写数据库的名称。", vbInformation
        txtfield(3).SetFocus
        Exit Sub
    End If
    
    Dim cnTest As New ADODB.Connection
    sqlConnect cnTest, txtfield(0).Text, txtfield(1).Text, txtfield(2).Text, txtfield(3).Text
    MsgBox "连接 " & txtfield(0).Text & " 成功!", vbInformation
    cnTest.Close
    SaveServer txtfield(0).Text, txtfield(1).Text, txtfield(2).Text, txtfield(3).Text
    readServer
    Unload Me
Exit Sub
aaaa:
    MsgBox Err.Description, vbCritical
    
End Select
End Sub

Private Sub txtField_KeyPress(Index As Integer, KeyAscii As Integer)

 If KeyAscii = 13 Then
    '自动下跳
     If Index < 3 Then                    '最后一个文本框
        txtfield(Index + 1).SetFocus
       Else
        txtfield(0).SetFocus               '返回
     End If
     Exit Sub
 End If
     
'判断是否为正确输入
 
         
 
 
End Sub

⌨️ 快捷键说明

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