?? 曲線f2.frm
字號:
VERSION 5.00
Begin VB.Form frmPicture
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "曲線"
ClientHeight = 8085
ClientLeft = 60
ClientTop = 345
ClientWidth = 14325
ControlBox = 0 'False
LinkTopic = "Form1"
ScaleHeight = 14.261
ScaleMode = 0 'User
ScaleWidth = 25.268
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdLittle
Caption = "1/2"
Height = 375
Left = 2520
TabIndex = 3
Top = 0
Width = 975
End
Begin VB.CommandButton cmdPrint
Caption = "打 印"
Height = 375
Left = 1680
TabIndex = 2
Top = 0
Width = 855
End
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 840
TabIndex = 1
Top = 0
Width = 855
End
Begin VB.CommandButton cmdDraw
Caption = "作 圖"
Height = 375
Left = 0
TabIndex = 0
Top = 0
Width = 855
End
Begin VB.Label lblTitle
Alignment = 2 'Center
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
Caption = "圖題"
DragMode = 1 'Automatic
BeginProperty Font
Name = "隸書"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 435
Left = 6960
TabIndex = 4
Top = 120
Width = 915
End
End
Attribute VB_Name = "frmPicture"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'圖形窗體
Option Explicit
Dim intI As Integer, intJ As Integer
Dim intFileNumber As Integer '文件號
Dim strData As String '臨時保存數(shù)據(jù)
Dim blnTitle As Boolean '是否有圖題
Dim blnRowLabel As Boolean '是否有行標(biāo)
Dim blnColLabel As Boolean '是否有列標(biāo)
Dim strColLabel() As String '列標(biāo)數(shù)組
Dim strRowLabel() As String '行標(biāo)數(shù)組
Dim dblData() As Double '圖形數(shù)據(jù)
Dim sngData() As Single '變換為坐標(biāo)值的圖形數(shù)據(jù)
Dim dblDatMin() As Double '極小值
Dim dblDatMax() As Double '極大值
Dim dblMaxMin As Double '極差
Dim sngXInc As Single '水平方向的坐標(biāo)增量
Dim sngYInc As Single '垂直方向的坐標(biāo)增量
Dim sngH As Single '窗體自定義高度單位等價的Twips
Dim sngCH As Single '曲線的高度
Dim intYScale(1 To 4) As Integer '縱軸的刻度值
Dim sngYScale(1 To 4) As Single '縱軸刻度的坐標(biāo)值
Dim intS As Integer, intS1 As Integer, intS2 As Integer
Private Sub Form_Load()
lblTitle.Visible = False
Me.Top = 0: Me.Left = 0
intS1 = 17: intS2 = 12
Me.Scale (0, 0)-(intS1, intS2) '窗體的自定義坐標(biāo)系
sngH = Me.Height / 12
cmdPrint.Visible = False
intFileNumber = FreeFile '取得空閑的文件號碼
Open strFileName For Input As intFileNumber
Input #intFileNumber, strData '讀列數(shù)
intCol = Val(strData) '取得列數(shù)
If intCol >= 2 Then
For intI = 2 To intCol '空轉(zhuǎn),讀*****
Input #intFileNumber, strData
Next intI
End If
Input #intFileNumber, strData '讀行數(shù)
intRow = Val(strData) '取得行數(shù)
If intCol >= 2 Then
For intI = 2 To intCol '空轉(zhuǎn),讀*****
Input #intFileNumber, strData
Next intI
End If
'重新定義圖形數(shù)據(jù)數(shù)組
ReDim dblData(1 To intRow, 1 To intCol) '原始數(shù)據(jù)
ReDim sngData(1 To intRow, 1 To intCol) '變換成坐標(biāo)后的數(shù)據(jù)
'重新定義每行的極值數(shù)組
ReDim dblDatMin(1 To intRow), dblDatMax(1 To intRow)
'確定曲線高度
'行數(shù)=曲線條數(shù)
'sngH是自定義高度單位所相當(dāng)?shù)腡wips數(shù)
If intRow <= 3 Then
sngCH = 3 '曲線高度為3單位
ElseIf intRow <= 6 Then
sngCH = 1.5 '曲線高度為1.5單位
ElseIf intRow <= 9 Then
sngCH = 1 '曲線高度為1個單位
ElseIf intRow <= 12 Then
sngCH = 0.4 '曲線的高度為0.8個單位
Else
MsgBox "行數(shù)小于1或行數(shù)大于12,無法作曲線圖,請檢查數(shù)據(jù)或開發(fā)新程序"
Load Me
End
End If
Me.Height = sngH * ((sngCH + 0.5) * intRow + 2) '窗體的高度
Input #intFileNumber, strData '讀總行數(shù)
intRowAll = Val(strData) '取得總行數(shù)
If intCol >= 2 Then
For intI = 2 To intCol '空轉(zhuǎn),讀*****
Input #intFileNumber, strData
Next intI
End If
blnTitle = False: blnRowLabel = False: blnColLabel = False
'優(yōu)先考慮圖題
If intRowAll > intRow + 3 Then blnTitle = True '有圖題
'其次考慮行標(biāo)
If intRowAll > 2 * intRow + 3 Then
blnRowLabel = True '有行標(biāo)
ReDim strRowLabel(1 To intRow) '重新定義行標(biāo)數(shù)組
End If
'最后考慮列標(biāo)
If intRowAll > 2 * intRow + 4 Then
blnColLabel = True '有列標(biāo)
ReDim strColLabel(1 To intCol) '重新定義列標(biāo)數(shù)組
End If
If blnTitle Then
lblTitle.Visible = True
Input #intFileNumber, strData '讀圖形標(biāo)題
lblTitle.Caption = strData '在圖題標(biāo)簽中顯示圖形標(biāo)題
lblTitle.Visible = True
If intCol >= 2 Then
For intI = 2 To intCol '空轉(zhuǎn),讀*****號
Input #intFileNumber, strData
Next intI
End If
End If
If blnRowLabel Then
For intI = 1 To intRow
Input #intFileNumber, strData '讀行標(biāo)題
strRowLabel(intI) = strData '在行標(biāo)標(biāo)簽中顯示行標(biāo)題
If intCol >= 2 Then
For intJ = 2 To intCol '空轉(zhuǎn),讀*****號
Input #intFileNumber, strData
Next intJ
End If
Next intI
End If
If blnColLabel Then
For intI = 1 To intCol '讀列標(biāo)題
Input #intFileNumber, strData
strColLabel(intI) = strData
Next intI
End If
For intI = 1 To intRow
For intJ = 1 To intCol
Input #intFileNumber, strData '讀圖形數(shù)據(jù)
dblData(intI, intJ) = Val(strData)
Next intJ
Next intI
Close
'列數(shù)=數(shù)據(jù)點個數(shù)
'sngXInc為水平方向的刻度間距
If intCol > 1 Then
sngXInc = 15 / (intCol - 1)
Else
MsgBox "列數(shù)不能小于等于1"
Unload Me
End
End If
'求出每行數(shù)據(jù)的極值
For intI = 1 To intRow
dblDatMin(intI) = 100000
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -