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

📄 form1.frm

📁 自动计算矩形的相关信息
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4980
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6975
   LinkTopic       =   "Form1"
   ScaleHeight     =   332
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   465
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "计算矩形"
      Height          =   615
      Left            =   6720
      TabIndex        =   4
      Top             =   1800
      Width           =   1815
   End
   Begin VB.ListBox List1 
      Height          =   4020
      Left            =   6600
      TabIndex        =   3
      Top             =   3000
      Width           =   2895
   End
   Begin VB.CommandButton Command2 
      Caption         =   "读坐标"
      Height          =   615
      Left            =   6720
      TabIndex        =   2
      Top             =   1200
      Width           =   1815
   End
   Begin VB.CommandButton Command1 
      Caption         =   "处理"
      Height          =   735
      Left            =   6720
      TabIndex        =   1
      Top             =   480
      Width           =   1815
   End
   Begin VB.PictureBox Picture1 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      Height          =   5760
      Left            =   360
      Picture         =   "Form1.frx":0000
      ScaleHeight     =   380
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   386
      TabIndex        =   0
      Top             =   480
      Width           =   5850
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Clipboard.SetData Picture1.Image
BlackWhite 128
noise
lk
Picture1.Picture = Clipboard.GetData
Clipboard.SetData Picture1.Image
Scan_Circle "c:\asun.txt"
End Sub

Private Sub Command2_Click()
Dim str As String
Dim X As Integer, Y As Integer, i As Integer

Open "c:\asun.txt" For Input As #1
ReDim temp(2000, 1)
num = 0
Do While Not EOF(1)

   Line Input #1, str
   If str <> ":" Then
      
   
      If str <> ":" Then
         X = X + 1
         If X Mod 2 <> 0 Then
            temp(Y, 0) = Val(str)
         Else
            temp(Y, 1) = Val(str)
            num = num + 1
            Y = Y + 1
         End If

     List1.AddItem str
    End If
   End If

Loop
For i = 0 To num - 1
  ' Picture1.PSet (temp(i, 0), temp(i, 1)), vbRed

Next
End Sub



Private Sub Command3_Click()
Dim x1, x2, x3, x4, y1, y2, y3, y4 As Single
Dim i As Integer
x1 = temp(0, 0)
x2 = temp(0, 0)
y3 = temp(0, 1)
y4 = temp(0, 1)
For i = 1 To num - 1     '取x最大值的坐标
   If x1 < temp(i, 0) Then
      x1 = temp(i, 0)
      y1 = temp(i, 1)
   End If

   If x2 > temp(i, 0) Then '取x最小值的坐标
      x2 = temp(i, 0)
      y2 = temp(i, 1)
   End If
   
   If y3 < temp(i, 1) Then '取y最大值的坐标
      x3 = temp(i, 0)
      y3 = temp(i, 1)
   End If
   
   'y的最小值就是temp(0,1)
Next
Picture1.Line (x1, y1)-(temp(0, 0), temp(0, 1)), vbRed
Picture1.Line (x2, y2)-(temp(0, 0), temp(0, 1)), vbRed
Picture1.Line (x1, y1)-(x3, y3), vbRed
Picture1.Line (x2, y2)-(x3, y3), vbRed
''''''temp(0,0),temp(0,1)   到x1y1的距离和到x2y2的距离就是矩形的长和宽
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Caption = str(X) & "  " & str(Y)
End Sub

⌨️ 快捷键说明

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