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

📄 comp.frm

📁 一个修改二进制文件的小程序,不过在打开大于1M的文件时耗时较长
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form3 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "比较"
   ClientHeight    =   3270
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   2535
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3270
   ScaleWidth      =   2535
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin MSComctlLib.ListView ListView1 
      Height          =   2775
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   4895
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "位置"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "文件1"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "文件2"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.CommandButton Command2 
      Caption         =   "关闭"
      Height          =   375
      Left            =   1440
      TabIndex        =   1
      Top             =   2880
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "开始"
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   2880
      Width           =   975
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private PosX As Single
Private PosY As Single

Private Sub Form_Load()
Dim Width As Long
With ListView1
Width = .Width
.ColumnHeaders(1).Width = 0.28 * Width
.ColumnHeaders(2).Width = 0.35 * Width
.ColumnHeaders(3).Width = 0.35 * Width
End With
Me.Icon = Form1.Icon
ListView1.ColumnHeaders(2).Text = GetFileTitle(CompName1)
ListView1.ColumnHeaders(3).Text = GetFileTitle(CompName2)
End Sub

Private Sub Command1_Click()
Dim a As Byte
Dim b As Byte
Dim l As Long
Dim CompItem As ListItem
Open CompName1 For Binary As #3
Open CompName2 For Binary As #4
If LOF(3) <> LOF(4) Then MsgBox "文件不匹配", vbCritical: Close #3, #4: Exit Sub
ListView1.MousePointer = rtfHourglass
ListView1.ListItems.Clear
ListView1.Refresh
l = 1
Get #3, , a
Get #4, , b
Do Until EOF(3)
    If a <> b Then
        Set CompItem = ListView1.ListItems.Add(, , l)
        CompItem.SubItems(1) = a
        CompItem.SubItems(2) = b
    End If
    Get #3, , a
    Get #4, , b
    l = l + 1
Loop
ListView1.MousePointer = 0
MsgBox "搜索完毕", vbInformation
Close #3, #4
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub ListView1_Click()
Dim lItem As ListItem
Set lItem = ListView1.HitTest(PosX, PosY)
If ListView1.SelectedItem Is Nothing Then Exit Sub
If lItem Is Nothing Then
    ListView1.SelectedItem.Selected = False
    Set ListView1.SelectedItem = Nothing
End If
End Sub

Private Sub ListView1_DblClick()
Dim lItem As ListItem
Dim a As String, n As Long
On Error Resume Next
Set lItem = ListView1.HitTest(PosX, PosY)
If lItem Is Nothing Then Exit Sub
If OpenName = CompName1 Or OpenName = CompName2 Then
    a = lItem.Text
    n = Val(a)
    With Form1.rdata
        .SelStart = 3 * n - 3
        .SelLength = 2
    End With
    Form1.SetFocus
End If
End Sub

Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Dim lItem As ListItem
    Dim a As String, n As Long
    Set lItem = ListView1.SelectedItem
    If lItem Is Nothing Then Exit Sub
    If OpenName = CompName1 Or OpenName = CompName2 Then
        a = lItem.Text
        n = Val(a)
        With Form1.rdata
            .SelStart = 3 * n - 3
            .SelLength = 2
        End With
        Form1.SetFocus
    End If
End If
End Sub

Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
PosX = x
PosY = y
End Sub

⌨️ 快捷键说明

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