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

📄 testform.frm

📁 支持PC机的各种端口的读写,包括,并口,串口,USB,等等
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Text            =   "303"
         Top             =   720
         Width           =   855
      End
      Begin VB.TextBox PortR2 
         Height          =   285
         Left            =   240
         TabIndex        =   9
         Text            =   "300"
         Top             =   1035
         Width           =   855
      End
      Begin VB.TextBox PortR3 
         Height          =   285
         Left            =   240
         TabIndex        =   8
         Text            =   "300"
         Top             =   1365
         Width           =   855
      End
      Begin VB.TextBox PortR4 
         Height          =   285
         Left            =   240
         TabIndex        =   7
         Text            =   "0"
         Top             =   1680
         Width           =   855
      End
      Begin VB.CommandButton Read_All 
         Caption         =   "Read all ports"
         Height          =   435
         Left            =   240
         TabIndex        =   6
         Top             =   2160
         Width           =   1890
      End
      Begin VB.CheckBox CR1 
         Caption         =   "Check5"
         Height          =   255
         Left            =   1920
         TabIndex        =   5
         Top             =   720
         Value           =   1  'Checked
         Width           =   255
      End
      Begin VB.CheckBox CR2 
         Caption         =   "Check6"
         Height          =   255
         Left            =   1920
         TabIndex        =   4
         Top             =   1040
         Value           =   1  'Checked
         Width           =   255
      End
      Begin VB.CheckBox CR3 
         Caption         =   "Check7"
         Height          =   255
         Left            =   1920
         TabIndex        =   3
         Top             =   1360
         Value           =   1  'Checked
         Width           =   255
      End
      Begin VB.CheckBox CR4 
         Caption         =   "Check8"
         Height          =   255
         Left            =   1920
         TabIndex        =   2
         Top             =   1680
         Width           =   255
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "Addr(hex)"
         Height          =   195
         Left            =   360
         TabIndex        =   16
         Top             =   360
         Width           =   675
      End
      Begin VB.Label Label11 
         Caption         =   "Value(hex)"
         Height          =   255
         Left            =   1200
         TabIndex        =   15
         Top             =   360
         Width           =   795
      End
      Begin VB.Label ValR1 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         Caption         =   "00"
         Height          =   285
         Left            =   1380
         TabIndex        =   14
         Top             =   720
         Width           =   375
      End
      Begin VB.Label ValR2 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         Caption         =   "00"
         Height          =   285
         Left            =   1380
         TabIndex        =   13
         Top             =   1035
         Width           =   375
      End
      Begin VB.Label ValR3 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         Caption         =   "00"
         Height          =   285
         Left            =   1380
         TabIndex        =   12
         Top             =   1365
         Width           =   375
      End
      Begin VB.Label ValR4 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         Caption         =   "00"
         Height          =   285
         Left            =   1380
         TabIndex        =   11
         Top             =   1680
         Width           =   375
      End
   End
   Begin VB.CheckBox C_Hard 
      Caption         =   """Hard"" access to the ports"
      Height          =   315
      Left            =   480
      TabIndex        =   0
      Top             =   3420
      Value           =   1  'Checked
      Width           =   2295
   End
End
Attribute VB_Name = "PortForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'=======================================================
'=====     Test example for TVicHW32.DLL 4.0       =====
'=======================================================
'== Copyright(c) 1999 Victor Ishikeev (ivi@ufanet.ru) ==
'=======================================================

Dim HW32 As Long
Dim ActiveHW As Boolean


Public Sub WriteToPort(Addr As TextBox, ValPort As TextBox, CW As CheckBox)
 Dim NomW As Integer, DatW As Integer
  If CW.Value = Checked Then
    NomW = HexToInt(Addr.Text)
    DatW = HexToInt(ValPort.Text)
    
'-------------------------------------
'---- Write one byte to the port  ----

    Call SetPortByte(HW32, NomW, DatW)
    
'-------------------------------------

  End If
End Sub

Public Sub ReadFromPort(Addr As TextBox, ValPort As Label, CR As CheckBox)
 Dim NomR As Long, DatR As Integer
  
  If CR.Value = Checked Then
    NomR = HexToInt(Addr.Text)
    
'---------------------------------
'-- Read one byte from the port --

    DatR = GetPortByte(HW32, NomR)
    
'---------------------------------

    ValPort.Caption = Hex(DatR)
  End If
  
End Sub

Private Sub B_Exit_Click()
  If ActiveHW Then HW32 = CloseTVicHW32(HW32)
  ActiveHW = False
  Unload PortForm
End Sub

Private Sub C_Hard_Click()
  Call SetHardAccess(HW32, C_Hard.Value)
End Sub

Private Sub Close_Driver_Click()
  HW32 = CloseTVicHW32(HW32)
  Open_Driver.Enabled = True
  Close_Driver.Enabled = False
  Read_All.Enabled = False
  Write_All.Enabled = False
  C_Hard.Enabled = True
End Sub

Private Sub Form_Load()
  HW32 = 0
  ActiveHW = False
  Open_Driver.Enabled = True
  Close_Driver.Enabled = False
  Read_All.Enabled = False
  Write_All.Enabled = False
  C_Hard.Enabled = False
  
End Sub

Private Sub Form_Unload(Cancel As Integer)
 If ActiveHW Then HW32 = CloseTVicHW32(HW32)
  ActiveHW = False
End Sub

Private Sub Open_Driver_Click()
  HW32 = 0
  If TVicDevice0 Then
    HW32 = OpenTVicHW32(HW32, "TVICHW32", "TVicDevice0")
  Else
    HW32 = OpenTVicHW32(HW32, "TVICHW32", "TVicDevice1")
  End If
  If GetActiveHW(HW32) Then
    Open_Driver.Enabled = False
    Close_Driver.Enabled = True
    Read_All.Enabled = True
    Write_All.Enabled = True
    ActiveHW = True
    C_Hard.Enabled = True
    C_Hard.Value = 1
  Else
    Call MsgBox("Can't open the driver!", 0, "Warning!")
  End If
    
End Sub

Private Sub Read_All_Click()
  Call ReadFromPort(PortR1, ValR1, CR1)
  Call ReadFromPort(PortR2, ValR2, CR2)
  Call ReadFromPort(PortR3, ValR3, CR3)
  Call ReadFromPort(PortR4, ValR4, CR4)
End Sub

Private Sub Write_All_Click()
  WriteToPort PortW1, ValW1, CW1
  WriteToPort PortW2, ValW2, CW2
  WriteToPort PortW3, ValW3, CW3
  WriteToPort PortW4, ValW4, CW4
End Sub

⌨️ 快捷键说明

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