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

📄 formmain.frm

📁 一个51单片机网卡的IP地址设置界面程序
💻 FRM
📖 第 1 页 / 共 4 页
字号:
      Top             =   960
      Visible         =   0   'False
      Width           =   315
   End
   Begin VB.Image Image9 
      Height          =   300
      Left            =   12720
      Picture         =   "Formmain.frx":2691FD
      Top             =   600
      Visible         =   0   'False
      Width           =   315
   End
   Begin VB.Image imgMinimize 
      Height          =   300
      Left            =   14640
      Picture         =   "Formmain.frx":269716
      Tag             =   "Minimize"
      ToolTipText     =   "Minimize"
      Top             =   0
      Width           =   315
   End
   Begin VB.Image imgClose 
      Height          =   315
      Left            =   15000
      Picture         =   "Formmain.frx":269C2F
      Tag             =   "Close"
      ToolTipText     =   "Close"
      Top             =   0
      Width           =   315
   End
End
Attribute VB_Name = "Formmain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwmilliseconds As Long)
'Private Declare Function TIMERGETTIME Lib "WINMM.DLL " Alias "TIMEGETTIME" () As Long


Private Sub Form_Load()
Combo1.ListIndex = 3
'MSComm1.PortOpen = True
Label22.Caption = GetIPAddress()
End Sub
Function mynetsend(X As Byte)

    
sckclient.SendData Chr(255) & Chr(X)

End Function

Private Sub Image10_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image10.Picture = Image16.Picture
End If

End Sub

Private Sub Image10_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image10.Picture = Image15.Picture
End If
End Sub

Private Sub Image11_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image11.Picture = Image16.Picture
End If
End Sub

Private Sub Image11_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image11.Picture = Image15.Picture
End If
End Sub

Private Sub Image12_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image12.Picture = Image16.Picture
End If

End Sub

Private Sub Image12_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image12.Picture = Image15.Picture
End If

End Sub

Private Sub Image13_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image13.Picture = Image16.Picture
End If
End Sub

Private Sub Image13_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image13.Picture = Image15.Picture
End If
End Sub

Private Sub Image14_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image14.Picture = Image16.Picture
End If
End Sub

Private Sub Image14_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image14.Picture = Image15.Picture
End If

End Sub

Private Sub Image4_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image4.Picture = Image16.Picture
End If
End Sub






Private Sub Image4_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image4.Picture = Image15.Picture
End If

End Sub

Private Sub Image7_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image7.Picture = Image16.Picture
End If
End Sub

Private Sub Image7_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image7.Picture = Image15.Picture
End If
End Sub

Private Sub imgClose_Click()
If MSComm1.PortOpen = True Then

 MSComm1.PortOpen = False
 End If
Unload Me

End Sub

Private Sub imgClose_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    imgClose.Picture = Image5.Picture
End If

End Sub

Private Sub imgMinimize_Click()
On Error Resume Next
Me.WindowState = vbMinimized

End Sub

Private Sub imgMinimize_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    imgMinimize.Picture = Image6.Picture
End If
End Sub

Private Sub imgMinimize_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    imgMinimize.Picture = Image9.Picture
End If

End Sub

Private Sub Label11_Click()
 On Error GoTo sendErr
 
 If MSComm1.PortOpen = False Then
 
 MSComm1.PortOpen = True
 
End If
                 '避免程序运行错误,发生死机
Dim i
MSComm1.Output = Chr(255)
For i = 1 To 100000 Step 1
Next i
For i = 1 To 100000 Step 1
Next i
For i = 1 To 100000 Step 1
Next i
MSComm1.Output = Chr(127)
Exit Sub



sendErr:
   MsgBox Err.Description               '显示错误信息

End Sub

Private Sub Label11_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image4.Picture = Image16.Picture
End If
End Sub

Private Sub Label11_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image4.Picture = Image15.Picture
End If

End Sub

Private Sub Label12_Click()
 On Error GoTo sendErr                 '避免程序运行错误,发生死机

   
    
    With sckclient
  .Close
    .RemoteHost = "192.168.0.7"
    .RemotePort = 7000                      '1024
    .LocalPort = 1234                           '1234
  
    
End With

Dim scom(27) As Byte
''------------------- THE FLLOWER CODE THE NETWORK CARD MAC ADDRESS----------------------'
scom(0) = "&h" + (Text1.Text)
scom(1) = "&h" + (Text2.Text)
scom(2) = "&h" + (Text3.Text)
scom(3) = "&h" + (Text4.Text)
scom(4) = "&h" + (Text5.Text)
scom(5) = "&h" + (Text6.Text)
''---------------  THE FLLOWER CODE IS  WILL CONFIG IP ADDRESS--------------------------
scom(6) = Val(Text7.Text)
scom(7) = Val(Text8.Text)
scom(8) = Val(Text9.Text)
scom(9) = Val(Text10.Text)

''---------------THE FLLOWER CODE IS WILL CONFIG THE LOCAL PORT (NO USE)--------------
scom(10) = &H40
scom(11) = &H0

''---------------THE FLOWER CODE IS REMOTE MANGER HOST COMPUTER IP ADDRESS------------
scom(12) = Val(Text19.Text)
scom(13) = Val(Text20.Text)
scom(14) = Val(Text21.Text)
scom(15) = Val(Text22.Text)

''----------------THE FLLOWER CODE IS WILL CONFIG THE REMOTE PORT--------------------
scom(16) = Val(Text23.Text) \ 256
scom(17) = Val(Text23.Text) Mod 256
''---------------the fllower code is netmask -----------------------------------
scom(18) = Val(Text11.Text)
scom(19) = Val(Text12.Text)
scom(20) = Val(Text13.Text)
scom(21) = Val(Text14.Text)
''---------------the fllower code is network gateway--------------------
scom(22) = Val(Text15.Text)
scom(23) = Val(Text16.Text)
scom(24) = Val(Text17.Text)
scom(25) = Val(Text18.Text)
''-------------------the fllowe code is network scress delay-----------

  Select Case Combo1.ListIndex
    Case 0
    scom(26) = Val(1)   '45
    Case 1
    scom(26) = Val(2)   '60
    Case 2
    scom(26) = Val(3)   '75
    Case 3
    scom(26) = Val(4)   '90
    Case 4
    scom(26) = Val(5)   '120
    Case 5
    scom(26) = Val(6)  ' 180
    Case 6
    scom(26) = Val(7)    '200
 End Select


scom(27) = &H7F


sckclient.SendData scom


Exit Sub
sendErr:
   MsgBox Err.Description               '显示错误信息

End Sub

Private Sub Label12_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image7.Picture = Image16.Picture
End If

End Sub

Private Sub Label12_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image7.Picture = Image15.Picture
End If
End Sub

Private Sub Label13_Click()
If MSComm1.PortOpen = True Then

 MSComm1.PortOpen = False
 End If
 
Unload Me
End Sub

Private Sub Label13_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image10.Picture = Image16.Picture
End If

End Sub

Private Sub Label13_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image10.Picture = Image15.Picture
End If

End Sub

Private Sub Label14_Click()
Dim i, j



Dim strIP As String
  Dim varValues As Variant
  
  strIP = GetIPAddress()
  
  varValues = Split(strIP, ".")
  
 
  


  For i = varValues(3) To 254 Step 1
  
   varValues(3) = varValues(3) + 1
  
    strIP = Join(varValues, ".")
  
  
     With sckclient
    .Close
    .RemoteHost = strIP
    .RemotePort = 6000                      '1024
    .LocalPort = 6000                           '1234
      
    End With
   
  
  
  sckclient.SendData Chr(255)
   
  
  Next i
  

 
'call sleep(1000)                      为延时一秒
End Sub

Private Sub Label14_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image11.Picture = Image16.Picture
End If

End Sub

Private Sub Label14_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image11.Picture = Image15.Picture
End If
End Sub

Private Sub Label15_Click()
 On Error GoTo sendErr                 '避免程序运行错误,发生死机

   Dim XX

XX = Text24.Text & "." & Text25.Text & "." & Text26.Text & "." & Text27.Text

    
    With sckclient
  .Close
    .RemoteHost = XX
    .RemotePort = 7000                      '1024
    .LocalPort = 1234                           '1234
  
    
End With

Dim scom(27) As Byte
''------------------- THE FLLOWER CODE THE NETWORK CARD MAC ADDRESS----------------------'
scom(0) = "&h" + (Text1.Text)
scom(1) = "&h" + (Text2.Text)
scom(2) = "&h" + (Text3.Text)
scom(3) = "&h" + (Text4.Text)
scom(4) = "&h" + (Text5.Text)
scom(5) = "&h" + (Text6.Text)
''---------------  THE FLLOWER CODE IS  WILL CONFIG IP ADDRESS--------------------------
scom(6) = Val(Text7.Text)
scom(7) = Val(Text8.Text)
scom(8) = Val(Text9.Text)
scom(9) = Val(Text10.Text)

''---------------THE FLLOWER CODE IS WILL CONFIG THE LOCAL PORT (NO USE)--------------
scom(10) = &H40
scom(11) = &H0

''---------------THE FLOWER CODE IS REMOTE MANGER HOST COMPUTER IP ADDRESS------------
scom(12) = Val(Text19.Text)
scom(13) = Val(Text20.Text)
scom(14) = Val(Text21.Text)
scom(15) = Val(Text22.Text)

''----------------THE FLLOWER CODE IS WILL CONFIG THE REMOTE PORT--------------------
scom(16) = Val(Text23.Text) \ 256
scom(17) = Val(Text23.Text) Mod 256
''---------------the fllower code is netmask -----------------------------------
scom(18) = Val(Text11.Text)
scom(19) = Val(Text12.Text)
scom(20) = Val(Text13.Text)
scom(21) = Val(Text14.Text)
''---------------the fllower code is network gateway--------------------
scom(22) = Val(Text15.Text)
scom(23) = Val(Text16.Text)
scom(24) = Val(Text17.Text)
scom(25) = Val(Text18.Text)
''-------------------the fllowe code is network scress delay-----------

  Select Case Combo1.ListIndex
    Case 0
    scom(26) = Val(1)   '45
    Case 1
    scom(26) = Val(2)   '60
    Case 2
    scom(26) = Val(3)   '75
    Case 3
    scom(26) = Val(4)   '90
    Case 4
    scom(26) = Val(5)   '120
    Case 5
    scom(26) = Val(6)  ' 180
    Case 6
    scom(26) = Val(7)    '200
 End Select


scom(27) = &H7F


sckclient.SendData scom


Exit Sub
sendErr:
   MsgBox Err.Description               '显示错误信息

End Sub

Private Sub Label15_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image12.Picture = Image16.Picture
End If

End Sub

Private Sub Label15_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image12.Picture = Image15.Picture
End If

End Sub

Private Sub Label17_Click()
 On Error GoTo sendErr                 '避免程序运行错误,发生死机

Dim XX

XX = Text24.Text & "." & Text25.Text & "." & Text26.Text & "." & Text27.Text
'Debug.Print XX

  With sckclient
  .Close
    .RemoteHost = XX
    .RemotePort = 6000                      '1024
    .LocalPort = 6000                           '1234
  
    
End With
'mynetsend (77)
sckclient.SendData Chr(255)

Exit Sub
sendErr:
   MsgBox Err.Description               '显示错误信息

End Sub

Private Sub Label17_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image13.Picture = Image16.Picture
End If

End Sub

Private Sub Label17_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    Image13.Picture = Image15.Picture
End If

End Sub

Private Sub Label18_Click()
On Error Resume Next

⌨️ 快捷键说明

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