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

📄 bodeplotter.frm

📁 采用VB编写的一个电路分析系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form bodeplotter 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "波特仪"
   ClientHeight    =   5325
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4005
   Icon            =   "bodeplotter.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5325
   ScaleWidth      =   4005
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Visible         =   0   'False
   Begin VB.CommandButton right 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   3120
      Picture         =   "bodeplotter.frx":0CCA
      Style           =   1  'Graphical
      TabIndex        =   25
      Top             =   2430
      Width           =   855
   End
   Begin VB.CommandButton left 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   2160
      Picture         =   "bodeplotter.frx":1798
      Style           =   1  'Graphical
      TabIndex        =   24
      Top             =   2430
      Width           =   855
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000A&
      Caption         =   "设置"
      ForeColor       =   &H80000008&
      Height          =   2655
      Left            =   0
      TabIndex        =   6
      Top             =   2640
      Width           =   4000
      Begin VB.Frame Frame4 
         Caption         =   "显示类型"
         Height          =   1080
         Left            =   2280
         TabIndex        =   20
         Top             =   1450
         Width           =   1575
         Begin VB.OptionButton dsp 
            Caption         =   "对数值"
            Height          =   255
            Index           =   2
            Left            =   120
            TabIndex        =   23
            Top             =   695
            Width           =   975
         End
         Begin VB.OptionButton dsp 
            Caption         =   "相对值"
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   22
            Top             =   455
            Width           =   975
         End
         Begin VB.OptionButton dsp 
            Caption         =   "真实值"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   21
            Top             =   215
            Value           =   -1  'True
            Width           =   975
         End
      End
      Begin VB.Frame Frame3 
         Height          =   975
         Left            =   120
         TabIndex        =   14
         Top             =   480
         Width           =   3735
         Begin VB.TextBox Text2 
            Alignment       =   1  'Right Justify
            Height          =   270
            Left            =   960
            TabIndex        =   19
            Text            =   "100"
            Top             =   600
            Width           =   1815
         End
         Begin VB.ListBox List1 
            Height          =   240
            ItemData        =   "bodeplotter.frx":2266
            Left            =   2880
            List            =   "bodeplotter.frx":2273
            TabIndex        =   17
            Top             =   240
            Width           =   855
         End
         Begin VB.TextBox Text1 
            Alignment       =   1  'Right Justify
            Height          =   270
            Left            =   960
            TabIndex        =   16
            Text            =   "1000"
            Top             =   240
            Width           =   1815
         End
         Begin VB.Label Label6 
            Alignment       =   2  'Center
            Caption         =   "采样数"
            Height          =   255
            Left            =   120
            TabIndex        =   18
            Top             =   600
            Width           =   735
         End
         Begin VB.Label Label5 
            Alignment       =   2  'Center
            Caption         =   "最大频率"
            Height          =   255
            Left            =   120
            TabIndex        =   15
            Top             =   240
            Width           =   735
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "接口"
         Height          =   1080
         Left            =   120
         TabIndex        =   9
         Top             =   1450
         Width           =   1695
         Begin VB.TextBox sourcevolt 
            Height          =   270
            Left            =   720
            TabIndex        =   27
            Text            =   "0"
            Top             =   700
            Width           =   855
         End
         Begin VB.TextBox zerocom 
            Height          =   270
            Left            =   720
            TabIndex        =   13
            Text            =   "0"
            Top             =   460
            Width           =   855
         End
         Begin VB.TextBox node 
            Height          =   270
            Left            =   720
            TabIndex        =   11
            Text            =   "1"
            Top             =   220
            Width           =   855
         End
         Begin VB.Label Label9 
            Alignment       =   2  'Center
            Caption         =   "绑定源"
            Height          =   255
            Left            =   15
            TabIndex        =   26
            Top             =   745
            Width           =   720
         End
         Begin VB.Label Label8 
            Alignment       =   2  'Center
            Caption         =   "共地端"
            Height          =   255
            Left            =   15
            TabIndex        =   12
            Top             =   505
            Width           =   735
         End
         Begin VB.Label Label7 
            Alignment       =   2  'Center
            Caption         =   "节点"
            Height          =   255
            Left            =   120
            TabIndex        =   10
            Top             =   260
            Width           =   495
         End
      End
      Begin VB.OptionButton PF 
         Caption         =   "相频特性"
         Height          =   255
         Left            =   2040
         TabIndex        =   8
         Top             =   240
         Width           =   1095
      End
      Begin VB.OptionButton AF 
         Caption         =   "幅频特性"
         Height          =   255
         Left            =   600
         TabIndex        =   7
         Top             =   240
         Value           =   -1  'True
         Width           =   1095
      End
   End
   Begin VB.PictureBox table 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000A&
      ForeColor       =   &H80000008&
      Height          =   2150
      Left            =   0
      ScaleHeight     =   2115
      ScaleWidth      =   3975
      TabIndex        =   0
      Top             =   0
      Width           =   4005
      Begin VB.PictureBox Paper 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   2000
         Left            =   0
         ScaleHeight     =   1965
         ScaleWidth      =   3975
         TabIndex        =   1
         Top             =   150
         Width           =   4000
         Begin VB.Line mesureline 
            BorderColor     =   &H00FF0000&
            X1              =   840
            X2              =   840
            Y1              =   0
            Y2              =   1920
         End
      End
      Begin VB.Image Mark 
         Appearance      =   0  'Flat
         Height          =   150
         Left            =   840
         MousePointer    =   9  'Size W E
         Picture         =   "bodeplotter.frx":2285
         Stretch         =   -1  'True
         Top             =   0
         Width           =   150
      End
   End
   Begin VB.Label nowfre 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   2880
      TabIndex        =   5
      Top             =   2160
      Width           =   1095
   End
   Begin VB.Label Label3 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000A&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "当前频率:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1920
      TabIndex        =   4
      Top             =   2160
      Width           =   975
   End
   Begin VB.Label nowvalue 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   720
      TabIndex        =   3
      Top             =   2160
      Width           =   1095
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000A&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "当前值:"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   0
      TabIndex        =   2
      Top             =   2160
      Width           =   855
   End
End
Attribute VB_Name = "bodeplotter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Dim retvalue As Long

Dim bodetype As Integer
Dim maxfrequency As Single
Dim State As Integer
Dim numbers As Integer
Dim com, disptype As Integer
Dim pnode As Integer
Dim values() As Single
Dim sourcevoltage As Integer
Dim oldx As Single


Sub clip()
mesureline.X1 = Mark.left + 53
mesureline.X2 = Mark.left + 53
If State = 1 Then
   nowfre.Caption = maxfrequency * Mark.left / 4000
   nowvalue.Caption = values(Fix(Mark.left / (4000 / numbers)) + 1)
End If
End Sub



Private Sub AF_Click()
bodetype = 0
End Sub

Private Sub dsp_Click(index As Integer)
disptype = index
End Sub



Private Sub Form_Load()
Dim k As Integer
 retvalue = SetWindowPos(Me.hwnd, -1, Me.CurrentX, Me.CurrentY, 273, 374, &H40)
    '置中窗体
    Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2

Call drawnet
numbers = 100
maxfrequency = 1000
pnode = 1
com = 0
Call clip
End Sub
Sub drawnet()
Dim k As Integer
For k = 0 To Paper.Width Step 80
 Paper.Line (k, 0)-(k, 2000), &HC0C0C0
Next k

For k = 0 To Paper.Height Step 80
 Paper.Line (0, k)-(4000, k), &HC0C0C0
Next k

End Sub
Private Sub Form_Unload(cancel As Integer)
If formstate = 1 Then
 cancel = 0
 Else
cancel = 1
bodeplotter.Hide
End If

End Sub

Private Sub left_Click()
If Mark.left > 40 Then
Mark.left = Mark.left - 20
Call clip
End If
End Sub

Private Sub Mark_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Source.Move Mark.left + (X - oldx)

If Mark.left > 3800 Then
Mark.left = 3800
ElseIf Mark.left < 40 Then
Mark.left = 40
End If
Call clip
End Sub

Private Sub Mark_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
oldx = X
Mark.Drag
End If
End Sub

Public Sub node_Change()
If node.Text <> "" Then
If CInt(node.Text) < nodecounts And CInt(nodecounts) >= 0 Then
pnode = CInt(node.Text)
Else
 MsgBox "请正确输入节点号!"
End If
End If
End Sub



Private Sub PF_Click()
bodetype = 1
End Sub

Private Sub right_Click()
If Mark.left < 4000 Then
Mark.left = Mark.left + 20
Call clip
End If
End Sub

Private Sub sourcevolt_Change()
If sourcevolt.Text <> "" Then
If (mapform.cell(CInt(sourcevolt.Text)).celltype = 3 Or mapform.cell(CInt(sourcevolt.Text)).celltype = 4) And mapform.cell(CInt(sourcevolt.Text)).celltag = 1 Then
sourcevoltage = CInt(sourcevolt.Text)
Else
MsgBox "请正确输入交流电源号!"
End If
End If
End Sub

Private Sub Text1_Change()
If Text1.Text <> "" Then
Dim temp As Long
temp = 1
If List1.ListIndex = 0 Then
temp = 1
ElseIf List1.ListIndex = 1 Then
temp = 1000
ElseIf List1.ListIndex = 2 Then
temp = 1000000
End If
If CSng(Text1.Text) > 0 Then
 maxfrequency = CSng(Text1.Text) * temp
Else
MsgBox "请输入正确的值!"
End If
End If
End Sub

Private Sub Text2_Change()
If Text2.Text <> "" Then
If CInt(Text2.Text) > 0 Then
numbers = CInt(Text2.Text)
End If
End If
End Sub

Public Sub zerocom_Change()
If zerocom.Text <> "" Then
If CInt(zerocom.Text) >= 0 Then
com = CInt(zerocom.Text)
Else
MsgBox "请正确输入节点号!"
End If
End If
End Sub
Sub drawmap()
Dim steps, k As Integer
Dim temp As Single
ReDim values(1 To numbers) As Single
Paper.Cls
Call drawnet
State = 1
steps = Fix(4000 / numbers)
'''''''''''''''to initial the value
Call wholeanalysis(1)

'''''''''''''''''''''''''''''''''''''
'''''to compute the node value!
For k = 1 To numbers
sourcemat(mapform.cell(sourcevoltage).cellvalue).frequency = maxfrequency * (k / numbers)
Call ACanalyse
 values(k) = getvalue
Next k
'''''to draw the bodecurves!
If disptype = 2 Then
  For k = 2 To numbers
   Paper.Line (steps * (k - 1), Fix(Log(values(k - 1)) * 100))-(steps * k, Fix(Log(values(k)) * 100))
  Next k
Else
  
  For k = 1 To numbers
    If values(k) > temp Then
      temp = values(k)
    End If
  Next k
  
  For k = 2 To numbers
   Paper.Line (steps * (k - 1), 2000 - Fix(values(k - 1) / temp * 2000))-(steps * k, 2000 - Fix(values(k) / temp * 2000))
  Next k
End If
Call clip
End Sub

Function getvalue()
If bodetype = 0 Then
getvalue = nodevinfo(pnode, 0).a - nodevinfo(com, 0).a
  If getvalue < 0 Then
    getvalue = Abs(getvalue)
  End If
Else
  getvalue = nodevinfo(pnode, 0).alpha - nodevinfo(com, 0).alpha
   If getvalue < 0 Then
   getvalue = getvalue + 360
   End If
End If
End Function
Public Sub plotter_start()
Dim flag As Integer
On Error GoTo marks
Call drawmap
flag = 1
marks::
  If flag = 0 Then
  MsgBox "电路尚不完善或电路中有错误,请先纠正再运行!"
  End If

End Sub

⌨️ 快捷键说明

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