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

📄 form1.frm

📁 一款电场线的教学软件可以自定义电荷多少
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1 
   Caption         =   "主窗口"
   ClientHeight    =   7575
   ClientLeft      =   1740
   ClientTop       =   1785
   ClientWidth     =   10590
   LinkTopic       =   "Form1"
   Moveable        =   0   'False
   ScaleHeight     =   7575
   ScaleMode       =   0  'User
   ScaleWidth      =   10590
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame4 
      Caption         =   "提示"
      Height          =   615
      Left            =   0
      TabIndex        =   14
      Top             =   6360
      Width           =   5295
      Begin VB.Label Label2 
         Caption         =   "你可以以拖放形式随意更改电荷的位置"
         Height          =   255
         Left            =   120
         TabIndex        =   15
         Top             =   240
         Width           =   4935
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "More>>"
      Height          =   375
      Left            =   9360
      TabIndex        =   12
      Top             =   6480
      Width           =   1215
   End
   Begin MSComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   255
      Left            =   0
      TabIndex        =   11
      Top             =   7320
      Width           =   10590
      _ExtentX        =   18680
      _ExtentY        =   450
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   7057
            MinWidth        =   7057
            Text            =   "电场线之窗--嘿嘿"
            TextSave        =   "电场线之窗--嘿嘿"
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   2
            Object.Width           =   7056
            MinWidth        =   7056
            Text            =   "WELCOM TO http://leon6827.126.com"
            TextSave        =   "WELCOM TO http://leon6827.126.com"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   2
            Object.Width           =   4058
            MinWidth        =   4058
            Text            =   "2003-11-15"
            TextSave        =   "2003-11-15"
         EndProperty
      EndProperty
   End
   Begin VB.Frame Frame3 
      BackColor       =   &H80000000&
      Caption         =   "WELCOM"
      Height          =   255
      Left            =   0
      TabIndex        =   10
      Top             =   0
      Width           =   10575
   End
   Begin VB.Frame Frame2 
      Caption         =   "设置区"
      Height          =   5800
      Left            =   7560
      TabIndex        =   5
      Top             =   360
      Width           =   3000
      Begin VB.HScrollBar HScrolls 
         Height          =   255
         Index           =   0
         Left            =   1800
         Max             =   2
         Min             =   -2
         TabIndex        =   9
         Top             =   480
         Value           =   2
         Width           =   1095
      End
      Begin VB.TextBox TextY 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   0
         Left            =   1200
         TabIndex        =   8
         Text            =   "Text1"
         Top             =   480
         Width           =   615
      End
      Begin VB.TextBox TextX 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   0
         Left            =   600
         TabIndex        =   7
         Text            =   "Text1"
         Top             =   480
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   " Qi          Xi           Yi           调节电量"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   2775
      End
      Begin VB.Label Labels 
         Height          =   255
         Index           =   0
         Left            =   0
         TabIndex        =   6
         Top             =   480
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "绘图区(7100*5400)"
      Height          =   5800
      Left            =   0
      TabIndex        =   3
      Top             =   360
      Width           =   7425
      Begin VB.PictureBox Picture1 
         Height          =   5415
         Left            =   120
         ScaleHeight     =   5355
         ScaleMode       =   0  'User
         ScaleWidth      =   7095
         TabIndex        =   4
         Top             =   240
         Width           =   7155
      End
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Exit"
      Height          =   375
      Left            =   8040
      TabIndex        =   2
      Top             =   6480
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Draw_U"
      Height          =   375
      Left            =   6720
      TabIndex        =   1
      Top             =   6480
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Draw_E"
      Height          =   375
      Left            =   5400
      TabIndex        =   0
      Top             =   6480
      Width           =   1215
   End
   Begin VB.Menu mnuMenu 
      Caption         =   "菜单"
      Begin VB.Menu mnuDrawE 
         Caption         =   "电场线"
         Shortcut        =   ^E
      End
      Begin VB.Menu mnuDrawU 
         Caption         =   "等势面"
         Shortcut        =   ^U
      End
      Begin VB.Menu mnuDrawQ 
         Caption         =   "画电荷"
         Shortcut        =   ^Q
      End
      Begin VB.Menu break 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "退出"
         Shortcut        =   ^X
      End
   End
   Begin VB.Menu mnuSetting 
      Caption         =   "设置"
      Begin VB.Menu mnuNum 
         Caption         =   "电荷数"
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuLineW 
         Caption         =   "线宽"
         Begin VB.Menu mnuLine1 
            Caption         =   "x1"
            Checked         =   -1  'True
         End
         Begin VB.Menu mnuLine2 
            Caption         =   "x2"
            Checked         =   -1  'True
         End
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "帮助"
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim q1, q2, x(16), y(16), dt, pi, m As Double
Dim p(160), q(160) As Double
Dim k, l As Double
Dim u As Double
Dim v As Double
Private Type CHARGE
    q As Double
    qx As Integer
    qy As Integer
    x(36) As Double
    y(36) As Double
End Type
Dim n As Integer
Dim qq() As CHARGE
Const R = 100
Dim Rr_E(), ex_E(), ey_E() As Double
Dim Rr_U(), ex_U(), ey_U() As Double
Dim drag As Boolean
Dim Index_Q As Integer
Dim linewidth As Integer
Dim u_pos(), u_neg() As Double



Rem ###############################################################################################################

Private Sub Form_Load()
    pi = Atn(1) * 4
    n = Val(Form3.Text1.Text)
    ReDim qq(n)
    Picture1.ScaleTop = 0
    Picture1.ScaleLeft = 0
    Picture1.ScaleHeight = Picture1.Height
    Picture1.ScaleWidth = Picture1.Width
    mnuLine2.Checked = True
    mnuLine1.Checked = False
    linewidth = 2
    For i = 1 To n - 1
        Load Labels(i)
            Labels(i).Left = Labels(i - 1).Left
            Labels(i).Top = Labels(i - 1).Top + 350
            Labels(i).Visible = True
        Load TextX(i)
            TextX(i).Left = TextX(i - 1).Left
            TextX(i).Top = TextX(i - 1).Top + 350
            TextX(i).Visible = True
        Load TextY(i)
            TextY(i).Left = TextY(i - 1).Left
            TextY(i).Top = TextY(i - 1).Top + 350
            TextY(i).Visible = True
        Load HScrolls(i)
            HScrolls(i).Left = HScrolls(i - 1).Left
            HScrolls(i).Top = HScrolls(i - 1).Top + 350
            HScrolls(i).Visible = True
    Next i
    
    For i = 0 To n - 1
        qq(i).q = HScrolls(i).Value / 19
        qq(i).qy = Picture1.ScaleHeight / 2
        If n = 1 Then
            qq(i).qx = Picture1.ScaleWidth / 2
        Else
            qq(i).qx = Picture1.ScaleWidth * (i + 1) / (n + 1)
        End If
        Labels(i).Caption = "q" & Str$(i) & "= " & Str$(qq(i).q * 19)
        TextX(i).Text = Str$(qq(i).qx)
        TextY(i).Text = Str$(qq(i).qy)
    Next i

End Sub



Private Sub HScrolls_Change(Index As Integer)
    qq(Index).q = HScrolls(Index).Value / 19
    Labels(Index).Caption = "q" & Str$(Index) & "= " & Str$(qq(Index).q * 19)
    Call Draw_Q
End Sub

Private Sub mnuDrawQ_Click()
    Call Draw_Q
End Sub

Private Sub mnuHelp_Click()
    MsgBox "Produced by Leon6827 !    ---Version 1.00"
End Sub

Private Sub mnuLine1_Click()
    mnuLine1.Checked = True
    mnuLine2.Checked = False
    linewidth = 1
End Sub

Private Sub mnuLine2_Click()
    mnuLine2.Checked = True
    mnuLine1.Checked = False
    linewidth = 2
End Sub

Private Sub TextX_Change(Index As Integer)
    qq(Index).qx = Int(Val(TextX(Index).Text))
    Picture1.Cls
    Call Draw_Q
End Sub

Private Sub TextY_Change(Index As Integer)
    qq(Index).qy = Int(Val(TextY(Index).Text))
    Picture1.Cls
    Call Draw_Q
End Sub

Private Sub Draw_Q()
    Picture1.Cls
    For i = 0 To n - 1
        Picture1.DrawWidth = 2
        Picture1.Circle (qq(i).qx, qq(i).qy), R, QBColor(12)
        Picture1.DrawWidth = 1
        Picture1.Line (qq(i).qx - R, qq(i).qy)-(qq(i).qx + R, qq(i).qy), QBColor(12)
        If qq(i).q > 0 Then
            Picture1.Line (qq(i).qx, qq(i).qy + R)-(qq(i).qx, qq(i).qy - R), QBColor(12)
        End If
    Next i
End Sub

Private Sub Command1_Click()
    Call Draw_E
End Sub

Private Sub Command2_Click()
    Call Draw_U
End Sub

Private Sub Command3_Click()
    Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Form3.Show
End Sub

Private Sub mnuDrawE_Click()
    Call Draw_E
End Sub

Private Sub mnuDrawU_Click()
    Call Draw_U
End Sub

Private Sub mnuExit_Click()
    Unload Me
End Sub

Private Sub mnuNum_Click()
    Unload Me
    Form3.Show
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        drag = False
        For i = 0 To n - 1
            If (x - qq(i).qx) ^ 2 + (y - qq(i).qy) ^ 2 <= R ^ 2 Then
                drag = True
                Index_Q = i
                Picture1.MousePointer = vbCrosshair
            End If
        Next i
    End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If drag = True Then
        Picture1.MousePointer = vbCrosshair
    End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If drag = True Then
        TextX(Index_Q).Text = Str$(Int(x))
        TextY(Index_Q).Text = Str$(Int(y))
        Picture1.Cls
        Call Draw_Q
    End If
End Sub

Private Function Calculate_U(ByVal x As Integer, ByVal y As Integer) As Double
    Dim sum As Double
    sum = 0
    For i = 0 To n - 1
        sum = sum + qq(i).q / ((qq(i).qx - x) ^ 2 + (qq(i).qy - y) ^ 2)
    Next i
    Calculate_U = sum
End Function

Private Sub Draw_U1()
    Dim max, min As Double
    max = Calculate_U(0, 0)
    min = Calculate_U(0, 0)
    Dim i As Integer
    Dim j As Integer
    For i = 0 To Picture1.ScaleWidth Step 10
        For j = 0 To Picture1.ScaleHeight Step 10
            If Calculate_U(i, j) >= max Then
                max = Calculate_U(i, j)

⌨️ 快捷键说明

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