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

📄 frmmain.frm

📁  本程序是在原来的单纯形法基础上改进的,主要用于分枝界定法求解的整数规划。  修正的地方:   1.运用勃兰特原则   2.人机互动
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form FrmMain 
   Caption         =   "单纯形法"
   ClientHeight    =   7095
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6540
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   7095
   ScaleWidth      =   6540
   StartUpPosition =   2  'CenterScreen
   WhatsThisButton =   -1  'True
   WhatsThisHelp   =   -1  'True
   Begin VB.CommandButton Cmd_Branch 
      Caption         =   "分枝界定"
      Enabled         =   0   'False
      Height          =   495
      Left            =   2280
      TabIndex        =   6
      Top             =   6240
      Width           =   1475
   End
   Begin MSFlexGridLib.MSFlexGrid MSGrid 
      Height          =   2775
      Left            =   600
      TabIndex        =   5
      Top             =   3000
      Width           =   5055
      _ExtentX        =   8916
      _ExtentY        =   4895
      _Version        =   393216
      Rows            =   11
      Cols            =   5
   End
   Begin VB.CommandButton Cmd_Exit 
      Caption         =   "退出"
      Height          =   495
      Left            =   3960
      TabIndex        =   4
      Top             =   6240
      Width           =   1575
   End
   Begin VB.Frame Frame2 
      Caption         =   "输入阵列"
      Height          =   2535
      Left            =   360
      TabIndex        =   1
      Top             =   240
      Width           =   5295
      Begin VB.TextBox TxtSubject 
         Height          =   1695
         Left            =   360
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   3
         Top             =   600
         Width           =   4455
      End
      Begin VB.Label Label3 
         Caption         =   "阵列数据"
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   2160
         TabIndex        =   2
         Top             =   240
         Width           =   855
      End
   End
   Begin VB.CommandButton Cmd_Calcuate 
      Caption         =   "计算"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   6240
      Width           =   1575
   End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
 Private Sub Cmd_Branch_Click()
 FrmBranch.Show 1
End Sub
Private Sub Cmd_Calcuate_Click()
  Dim i%, j%
  On Error GoTo myError
  FrmMain.Cls
  cs = ""
  Dim Filenumber As Integer
  Dim tt As Integer '判断非基变量用
  Dim strPrint As String, strPrintResult As String
  Filenumber = FreeFile
  Open strFile For Input As #Filenumber
  Input #Filenumber, m, n  ' m为约束变量,n为约束条件数
  ReDim C(m) '价值系数
  ReDim ibs(n) '基变量序列号
  ReDim A(n, m) '约束矩阵
  ReDim Cb(n) '基变量的价值系数
  ReDim b(n)  '右端项值
  
  ReDim CA(m) '价值系数
  ReDim ibsA(n) '基变量序列号
  ReDim AA(n, m) '约束矩阵
  ReDim CbA(n) '基变量的价值系数
  ReDim bA(n)  '右端项值
  
  For i = 1 To m   'i代表横向,j代表纵向
     Input #Filenumber, C(i)  '价值系数
     CA(i) = C(i)
  Next i
  For j = 1 To n
     Input #Filenumber, ibs(j) '基变量序列号
     ibsA(j) = ibs(j)
  Next j
  For j = 1 To n
     For i = 1 To m
       Input #Filenumber, A(j, i) '矩阵
       AA(j, i) = A(j, i)
     Next i
     Input #Filenumber, b(j)
     bA(j) = b(j)
  Next j
  Close #Filenumber
  
  lineprog A, b, C, ibs, m, n
  
  MSGrid.TextMatrix(1, 1) = XX(1)
  MSGrid.TextMatrix(2, 1) = XX(2)
  MSGrid.TextMatrix(6, 1) = XX(3)
  Cmd_Branch.Enabled = True
  Exit Sub
myError:
MsgBox "输入的文件结构可能不符合要求,请检查后重试!", 0 + 16 + 0, "程序运行有故障"
End Sub
Private Sub Cmd_exit_Click()
  End
End Sub


Private Sub Form_Load()
  strFile = App.Path + "\inifile\matrix.txt"
  Open App.Path + "\inifile\matrix.txt" For Input As 1
  Dim nextline As String
  strTxt = ""
  Do Until EOF(1)
    Line Input #1, nextline
    strTxt = strTxt & nextline & Chr(13) & Chr(10)
  Loop
  Close #1
  TxtSubject.Text = strTxt
  MSGrid.TextMatrix(0, 0) = "约束变量值"
  MSGrid.TextMatrix(1, 0) = "    x1   "
  MSGrid.TextMatrix(2, 0) = "    x2   "
  MSGrid.TextMatrix(6, 0) = " 目标值 "
  MSGrid.TextMatrix(0, 1) = "   结果  "
  
End Sub


Private Sub TxtSubject_KeyUp(KeyCode As Integer, Shift As Integer)
  Dim Filenumber As Integer
  Filenumber = FreeFile
  Open strFile For Output As #Filenumber
  Print #1, TxtSubject.Text
  Close #Filenumber
End Sub

Private Sub TxtSubject_LostFocus()
  Open App.Path + "\inifile\matrix.txt" For Input As 1
  Dim nextline As String
  strTxt = ""
  Do Until EOF(1)
    Line Input #1, nextline
    strTxt = strTxt & nextline & Chr(13) & Chr(10)
  Loop
  Close #1
  TxtSubject.Text = strTxt
End Sub

⌨️ 快捷键说明

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