📄 多边形面积.frm
字号:
VERSION 5.00
Object = "{D76D7130-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "VSFLEX7D.OCX"
Begin VB.Form frmdbxmj
BorderStyle = 3 'Fixed Dialog
Caption = "多边形面积计算"
ClientHeight = 4500
ClientLeft = 45
ClientTop = 345
ClientWidth = 5340
Icon = "多边形面积.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4500
ScaleWidth = 5340
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command3
Height = 375
Left = 3000
Picture = "多边形面积.frx":0442
Style = 1 'Graphical
TabIndex = 10
ToolTipText = "下一个"
Top = 4080
Width = 375
End
Begin VB.Frame Frame2
Caption = "计算结果"
Height = 3255
Left = 3000
TabIndex = 8
Top = 720
Width = 2295
Begin VB.ListBox List1
Height = 2940
Left = 120
TabIndex = 9
Top = 240
Width = 2055
End
End
Begin VSFlex7DAOCtl.VSFlexGrid VSFlexGrid1
Height = 3615
Left = 0
TabIndex = 2
ToolTipText = "从起点到终点;不需要从起点到起点。"
Top = 840
Width = 2895
_cx = 5106
_cy = 6376
_ConvInfo = 1
Appearance = 1
BorderStyle = 1
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
MousePointer = 0
BackColor = -2147483643
ForeColor = -2147483640
BackColorFixed = -2147483633
ForeColorFixed = -2147483630
BackColorSel = -2147483635
ForeColorSel = -2147483634
BackColorBkg = 14737632
BackColorAlternate= -2147483643
GridColor = -2147483633
GridColorFixed = -2147483632
TreeColor = -2147483632
FloodColor = 192
SheetBorder = -2147483642
FocusRect = 3
HighLight = 1
AllowSelection = -1 'True
AllowBigSelection= -1 'True
AllowUserResizing= 3
SelectionMode = 0
GridLines = 1
GridLinesFixed = 2
GridLineWidth = 1
Rows = 2
Cols = 3
FixedRows = 1
FixedCols = 1
RowHeightMin = 0
RowHeightMax = 0
ColWidthMin = 0
ColWidthMax = 0
ExtendLastCol = 0 'False
FormatString = ""
ScrollTrack = 0 'False
ScrollBars = 3
ScrollTips = 0 'False
MergeCells = 0
MergeCompare = 0
AutoResize = -1 'True
AutoSizeMode = 0
AutoSearch = 0
AutoSearchDelay = 2
MultiTotals = -1 'True
SubtotalPosition= 1
OutlineBar = 0
OutlineCol = 0
Ellipsis = 0
ExplorerBar = 0
PicturesOver = 0 'False
FillStyle = 0
RightToLeft = 0 'False
PictureType = 0
TabBehavior = 0
OwnerDraw = 0
Editable = 2
ShowComboButton = -1 'True
WordWrap = 0 'False
TextStyle = 0
TextStyleFixed = 0
OleDragMode = 0
OleDropMode = 0
DataMode = 0
VirtualData = -1 'True
ComboSearch = 3
AutoSizeMouse = -1 'True
FrozenRows = 0
FrozenCols = 0
AllowUserFreezing= 3
BackColorFrozen = 0
ForeColorFrozen = 0
WallPaperAlignment= 9
End
Begin VB.Frame Frame1
Caption = "原始数据"
Height = 615
Left = 0
TabIndex = 5
Top = 40
Width = 5295
Begin VB.TextBox Text2
Height = 270
Left = 4200
TabIndex = 1
Text = "Text2"
ToolTipText = "输入后请回车,可不输入。"
Top = 240
Width = 975
End
Begin VB.TextBox Text1
Height = 270
Left = 840
TabIndex = 0
Text = "Text1"
Top = 240
Width = 975
End
Begin VB.Label Label2
Caption = "坐标组数="
Height = 255
Left = 3240
TabIndex = 7
Top = 285
Width = 975
End
Begin VB.Label Label1
Caption = "桩号ZJ="
Height = 255
Left = 120
TabIndex = 6
Top = 280
Width = 735
End
End
Begin VB.CommandButton Command2
Caption = "计算"
Height = 375
Left = 3480
TabIndex = 3
Top = 4080
Width = 855
End
Begin VB.CommandButton Command1
Caption = "关闭"
Height = 375
Left = 4440
TabIndex = 4
Top = 4080
Width = 855
End
End
Attribute VB_Name = "frmdbxmj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x(), y() As Double
Private Sub Command1_Click()
'关闭
On Error GoTo handlerror
If List1.ListCount > 1 And rjsfzc = 88 Then
frmMain.Text1 = frmMain.Text1 & vbCrLf & ""
frmMain.Text1 = frmMain.Text1 & vbCrLf & " 《多边形面积计算结果》:"
For i = 0 To List1.ListCount - 1
frmMain.Text1 = frmMain.Text1 & vbCrLf & " " + List1.List(i)
Next i
frmMain.Text1 = frmMain.Text1 & vbCrLf & " --------------------------------------"
End If
Unload Me
Exit Sub
handlerror:
End Sub
Private Sub Command2_Click()
'计算
On Error GoTo handlerror
num = Val(Text2.Text)
ReDim x(num), y(num)
For i = 1 To num
x(i) = Val(VSFlexGrid1.TextMatrix(i, 1))
y(i) = Val(VSFlexGrid1.TextMatrix(i, 2))
Next i
aw = 0
For i = 1 To num - 1
aw = aw + (y(i + 1) + y(i)) / 2 * (x(i + 1) - x(i))
Next i
aw = aw + (y(1) + y(num)) / 2 * (x(1) - x(num))
List1.AddItem " " + Text1.Text + " " + Str(Int(Abs(aw) * 1000 + 0.5) / 1000)
Exit Sub
handlerror:
xianshi = MsgBox("请检查输入的数据后,再计算试试。", vbInformation, "问题提示")
End Sub
Private Sub Command3_Click()
'下一个
Dim i As Integer
On Error GoTo handlerror
Text1.Text = ""
Text2.Text = ""
For i = 1 To VSFlexGrid1.Rows - 1
For j = 0 To VSFlexGrid1.Cols - 1
VSFlexGrid1.TextMatrix(i, j) = ""
Next j
Next i
VSFlexGrid1.Rows = 4
For i = 1 To 3
VSFlexGrid1.TextMatrix(i, 0) = i
Next i
Text1.SetFocus
Exit Sub
handlerror:
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
'Esc键退出,VbEscape可以用27代替
On Error GoTo handlerror
If KeyAscii = 27 Then
Unload Me
End If
Exit Sub
handlerror:
End Sub
Private Sub Form_Load()
'启动
Dim i As Integer
On Error GoTo handlerror
Text1.Text = ""
Text2.Text = ""
List1.Clear
With VSFlexGrid1
.Rows = 4
.TextMatrix(0, 0) = "序号"
.TextMatrix(0, 1) = "坐标X"
.TextMatrix(0, 2) = "坐标Y"
.ColAlignment(0) = flexAlignCenterCenter
.ColAlignment(1) = flexAlignCenterCenter
.ColAlignment(2) = flexAlignCenterCenter
.ColWidth(0) = 500
.ColWidth(1) = 1000
.ColWidth(2) = 1000
For i = 1 To 3
.TextMatrix(i, 0) = i
Next i
End With
List1.AddItem " 桩号" + " " + "面积(m2)"
Exit Sub
handlerror:
End Sub
Private Sub List1_DblClick()
'双击删除
On Error GoTo handlerror
List1.RemoveItem (List1.ListIndex)
Exit Sub
handlerror:
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
Text2.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
If Val(Text2.Text) >= 3 Then
VSFlexGrid1.Rows = Val(Text2.Text) + 1
For i = 1 To VSFlexGrid1.Rows - 1
VSFlexGrid1.TextMatrix(i, 0) = i
Next i
End If
End If
Exit Sub
handlerror:
End Sub
Private Sub VSFlexGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
'在编辑后组数
Dim i As Integer
On Error GoTo handlerror
If VSFlexGrid1.Row = VSFlexGrid1.Rows - 1 Then
Text2.Text = Trim(Str(VSFlexGrid1.Rows - 1))
i = VSFlexGrid1.Rows
VSFlexGrid1.Rows = i + 1
For i = 1 To VSFlexGrid1.Rows - 1
VSFlexGrid1.TextMatrix(i, 0) = i
Next i
End If
If VSFlexGrid1.Col = 1 Then
VSFlexGrid1.Col = 2
ElseIf VSFlexGrid1.Col = 2 Then
VSFlexGrid1.Col = 1
VSFlexGrid1.Row = VSFlexGrid1.Row + 1
End If
Exit Sub
handlerror:
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -