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

📄 frmipmanage.frm

📁 设置IP地址工具
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         TabIndex        =   25
         Top             =   2130
         Width           =   1245
      End
      Begin VB.Label lblAddress 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "默认网关"
         Height          =   195
         Index           =   3
         Left            =   570
         TabIndex        =   24
         Top             =   1245
         Width           =   720
      End
      Begin VB.Label lblAddress 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "子网掩码"
         Height          =   195
         Index           =   2
         Left            =   570
         TabIndex        =   23
         Top             =   855
         Width           =   720
      End
      Begin VB.Label lblAddress 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "IP地址"
         Height          =   195
         Index           =   1
         Left            =   570
         TabIndex        =   22
         Top             =   465
         Width           =   510
      End
      Begin VB.Label lblAddress 
         AutoSize        =   -1  'True
         Caption         =   "IP地址"
         Height          =   195
         Index           =   0
         Left            =   195
         TabIndex        =   21
         Top             =   105
         Width           =   510
      End
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "其输入实例名称:"
      Height          =   195
      Left            =   0
      TabIndex        =   32
      Top             =   0
      Width           =   1305
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "IP地址设置:"
      ForeColor       =   &H00C00000&
      Height          =   195
      Left            =   0
      TabIndex        =   31
      Top             =   705
      Width           =   915
   End
End
Attribute VB_Name = "FrmIpManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public m_CurrProfile As String
Public IsExit As Boolean
Public Sub ClearFields()
  Dim ctl As TextBox
  For Each ctl In Me.txtIP
    ctl.Text = ""
  Next
  txtProfileName.Text = ""
End Sub

Private Sub cmdCancel_Click()
  IsExit = True
  Unload Me
End Sub

Private Sub cmdSave_Click()
    
    Dim i%
    Dim strIPValues
   ' On Error GoTo ErrMsg
  If ValidateFields <> -1 Then
   ' MsgBox MLSGetString("0022") ' MLS-> "One or more value is missing."
    If ValidateFields = -2 Then
      txtProfileName.SetFocus
    Else
      txtIP(ValidateFields).SetFocus
    End If
    Exit Sub
  End If
  
'  If eProfileMode = PROF_MODE_EDIT Then
'    CIni.WriteString INI_SECTION_PROFILES, m_CurrProfile, vbNullString
'  End If
  
  For i = 0 To txtIP.Count - 1
    If txtIP(i).Text <> "" Then
        
        If strIPValues = "" Then
            strIPValues = txtIP(i)
        Else
            strIPValues = strIPValues & "." & txtIP(i)
        End If
    End If
  Next i
  CIni.WriteString INI_SECTION_PROFILES, Me.txtProfileName.Text, strIPValues
  Unload Me
  Exit Sub
ErrMsg:
  MsgBox Err.Description, vbInformation, HINT
  
End Sub

Private Sub txtIP_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)

      Select Case KeyCode
        Case vbKeyBack
          If txtIP(Index).SelLength > 0 Then
            txtIP(Index).SelLength = 0
            txtIP(Index).SelStart = Len(txtIP(Index).Text)
          End If
          
        Case vbKeyLeft
          If txtIP(Index).SelStart = 0 Then
            If Index > 0 Then
              If txtIP(Index).SelLength > 0 Then
                txtIP(Index).SelLength = 0
              Else
                SendKeys "+{TAB}"
              End If
            End If
          End If
        
        Case vbKeyRight
          If txtIP(Index).SelStart = Len(txtIP(Index).Text) Then
            SendKeys "{TAB}"
          End If
      End Select
End Sub

Private Sub txtIP_KeyPress(Index As Integer, KeyAscii As Integer)
  
  KeyAscii = ValidateNumberChar(KeyAscii)
  
  If KeyAscii = vbKeyReturn Then
    KeyAscii = 0
    Exit Sub
  End If

  If KeyAscii = vbKeyBack Then
    If txtIP(Index).SelStart = 0 Then
      SendKeys "+{TAB}"
    End If
    Exit Sub
  End If
  
  
  If KeyAscii = 46 Then
    KeyAscii = 0
  End If
  
End Sub



'---------------------------------------------------------------------------------------
' Procedure   : ValidateFields
' DateTime    : 14/06/2005 13.45
' Author      : Giorgio Brausi (vbcorner@vbcorner.net - http://www.vbcorner.net)
' Purpose     : Check for empty fields
' Return value: -1 if OK,
'               -2 if profile name is missing
'               otherwise the <index> for txtIP where field is empty
'
'---------------------------------------------------------------------------------------
Public Function ValidateFields() As Long
  Dim i As Integer
  
  ValidateFields = -1
  
  If Len(Trim(txtProfileName.Text)) = 0 Then
      ValidateFields = -2
      Exit Function
  End If
  
  Rem Check for empty fields, excluded 'Alternate DNS'
  For i = 0 To 11
    If Len(Trim(txtIP(i))) = 0 Then
      ValidateFields = i
      Exit Function
    End If
  Next
  
End Function

Private Sub txtIP_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
  
  Select Case KeyCode
    Rem Enter go to next control
    Case vbKeySeparator, vbKeyReturn, vbKeyDecimal, 190
      KeyCode = 0
      SendKeys "{TAB}"
          
    Case 48 To 57, 96 To 105 ' if press a digit
      If Len(txtIP(Index).Text) = 3 Then
        Rem if field contain 3 digit, go to next field
        SendKeys "{TAB}"
      End If
      
    Case Else
            
  End Select

End Sub

Private Sub txtIP_LostFocus(Index As Integer)

  OnFocus txtIP(Index), False
  
  If txtIP(Index).Text = "" Then Exit Sub
  
  Select Case Index
    Case 3
                
        If Int(txtIP(0).Text) = 127 Or Int(txtIP(0).Text) > 223 Then
            txtIP(0).SetFocus
            Exit Sub
        End If
        Select Case Int(txtIP(0).Text)
            Rem Address class IP type  "A"
            Case 1 To 126
                txtIP(4).Text = "255"
                txtIP(5).Text = "0"
                txtIP(6).Text = "0"
                txtIP(7).Text = "0"
                
            Rem Address class IP type "B"
            Case 128 To 191
                txtIP(4).Text = "255"
                txtIP(5).Text = "255"
                txtIP(6).Text = "0"
                txtIP(7).Text = "0"
            Rem Address class IP type  "C"
            Case 192 To 223
                txtIP(4).Text = "255"
                txtIP(5).Text = "255"
                txtIP(6).Text = "255"
                txtIP(7).Text = "0"
        End Select
  End Select
  
End Sub


Private Sub txtProfileName_GotFocus()
  OnFocus txtProfileName, True
End Sub


Private Sub txtProfileName_KeyPress(KeyAscii As Integer)
  Rem prevent beep
  If KeyAscii = vbKeyReturn Then
    KeyAscii = 0
  End If
  
End Sub

Private Sub txtProfileName_KeyUp(KeyCode As Integer, Shift As Integer)
  Rem Enter go to the next control
  If KeyCode = vbKeyReturn Then
    KeyCode = 0
    SendKeys "{TAB}"
  End If

End Sub

Private Sub txtProfileName_LostFocus()
  OnFocus txtProfileName, False
End Sub



⌨️ 快捷键说明

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