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

📄 form1.frm

📁 经曲的字符串匹配模糊搜索算法 思想不是本人的
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4695
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6840
   LinkTopic       =   "Form1"
   ScaleHeight     =   4695
   ScaleWidth      =   6840
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   6240
      Top             =   960
   End
   Begin MSComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   375
      Left            =   0
      TabIndex        =   4
      Top             =   4320
      Width           =   6840
      _ExtentX        =   12065
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3882
            MinWidth        =   3882
            Text            =   "         久基网络公司开发"
            TextSave        =   "         久基网络公司开发"
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3352
            MinWidth        =   3352
            Text            =   "           祁大江制作"
            TextSave        =   "           祁大江制作"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   5292
            MinWidth        =   5292
         EndProperty
      EndProperty
   End
   Begin VB.TextBox Text2 
      Height          =   2055
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   3
      Top             =   1920
      Width           =   6015
   End
   Begin VB.CommandButton Command1 
      Caption         =   "查询"
      Height          =   495
      Left            =   5160
      TabIndex        =   2
      Top             =   120
      Width           =   1455
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   2520
      TabIndex        =   0
      Top             =   120
      Width           =   2415
   End
   Begin VB.Label Label3 
      Height          =   255
      Left            =   2640
      TabIndex        =   6
      Top             =   1200
      Width           =   3015
   End
   Begin VB.Label Label2 
      Caption         =   "搜索所有时间为:"
      Height          =   255
      Left            =   240
      TabIndex        =   5
      Top             =   1200
      Width           =   1815
   End
   Begin VB.Label Label1 
      Caption         =   "请输入要查询的字符串"
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function timeGetTime Lib "winmm.dll" () As Long '声明API函数timeGetTime,用来计算时间

Private Sub Command1_Click()
    Dim strinquire As String
    Dim sum As Integer
    Dim tmpstr As String
    Dim strjieguo As String
    Dim i As Integer
    Dim tm1 As Long                                             '记录开始时间
    Dim tm2 As Long                                             '记录结束时间
    strinquire = Text1.Text
    sum = Len(strinquire)
    strjieguo = Empty
    If sum > 0 Then
        tm1 = timeGetTime '计算开始时的时间
        Open App.Path + "\111.txt" For Input As #1
            While Not EOF(1)
                tmpstr = Empty
                Line Input #1, tmpstr
                result = stringMatch(strinquire, tmpstr)
                Debug.Print "result= " & result
                If result >= 0.5 Then
                    strjieguo = strjieguo & "字符串  " & strinquire & "  与字符串  " & tmpstr & "  相似度为  " & result & vbCrLf
                Else
                    strjieguo = strjieguo & "字符串  " & strinquire & "  与字符串  " & tmpstr & "  相似度为  " & result & ";     " & result & "<0.5,不匹配! " & vbCrLf
                End If
                Text2 = strjieguo
            Wend
        Close #1
        'Open App.Path + "\jieguo.txt" For Append As #2  '不覆盖写
        Open App.Path + "\jieguo.txt" For Output As #2
            Write #2, strjieguo
        Close #2
        tm2 = timeGetTime '计算结束时的时间
    Else
        MsgBox "不能输入空字符串"
        Exit Sub
    End If
    Label3.Caption = "计算所用时间为" & Format((tm2 - tm1) / 1000, "0.000") & "秒"
    'Debug.Print "result= " & result
    'MsgBox "result=" & result
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub

Private Sub Form_Load()
'Dim result As Double
'result = stringMatch("kkkkkkkk", "ggggkjjj")
'MsgBox "result=" & result
'Dim result As Integer
'result = stringCoverMatch("qddddidajiang", "qdddddajiang")
'MsgBox "result=" & result
End Sub

'******************************************************
'用状态栏显示系统日期和时间
'******************************************************
Private Sub timer1_timer()
StatusBar1.Panels(3).Text = Format(Date, "long date") + "  " + Format(Now, "hh点mm分ss秒")
End Sub

⌨️ 快捷键说明

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