📄 txt.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5100
ClientLeft = 165
ClientTop = 495
ClientWidth = 6630
LinkTopic = "Form1"
ScaleHeight = 5100
ScaleWidth = 6630
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4200
Top = 720
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 3840
TabIndex = 0
Top = 3360
Width = 975
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 495
Left = 1320
TabIndex = 2
Top = 3360
Width = 975
End
Begin VB.TextBox Text1
Height = 615
Left = 3360
TabIndex = 1
Top = 1680
Width = 1335
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "日平均值:"
BeginProperty Font
Name = "仿宋_GB2312"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 960
TabIndex = 3
Top = 1800
Width = 2250
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
'*************日平均水位、流量计算
Private Sub Command1_Click()
Dim strline As String, rpj As Single, filename As String, dsj!(), a!
Call daoru(filename)
Open filename For Input As #1
Call jisuan(dsj!(), a!)
rpj = a / 24
Text1.Text = Format(rpj, "#.##")
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub jisuan(dsj!(), a!)
Dim sj!(), sw!(), dsj1!(), dsj2!(), i%, j%, swpj!(), mj!(), xs%, m%, n$, nn%, q!(), s!()
i = 1
Do Until EOF(1)
Line Input #1, strline
ReDim Preserve sj(i), sw(i), q!(i), s!(i)
m = InStr(strline, ",")
sj(i) = Val(Left(strline, m))
n = Mid(strline, m + 1)
nn = InStr(n, ",")
If nn = 0 Then 'txt文本中有1个逗号,说明是水位或流量资料,有两个数组:时间和水位
sw(i) = Val(Mid(strline, m + 1))
Else 'txt文本中有2个逗号,说明是输沙量资料,有三个数组:时间、流量和输沙量
q(i) = Val(Left(n, nn))
s(i) = Val(Mid(n, nn + 1))
sw(i) = q(i) * s(i)
End If
i = i + 1
Loop
Close #1
xs = i - 1
'************时间差计算
ReDim dsj1!(xs - 1), dsj2!(xs - 1), dsj!(xs - 1), swpj(xs - 1), mj(xs - 1)
If sj(1) > sj(2) Then
dsj01 = (24 - sj(1) - Int(24 - sj(1))) * 100 / 60 + Int(24 - sj(1))
dsj02 = (sj(2) - Int(sj(2))) * 100 / 60 + Int(sj(2)) + dsj01
sj(1) = 0
sw(1) = dsj01 / dsj02 * (sw(2) - sw(1)) + sw(1)
End If
If sj(xs) < sj(xs - 1) Then
dsj03 = (24 - Int(sj(xs - 1))) - ((sj(xs - 1) - Int(sj(xs - 1)))) * 100 / 60 + 24 - Int(sj(xs - 1)) 'dui
dsj04 = (sj(xs) + 24 - sj(xs - 1) - Int(sj(xs) + 24 - sj(xs - 1))) * 100 / 60 + Int(sj(xs) + 24 - sj(xs - 1))
sj(xs) = 24
sw(xs) = dsj01 / dsj02 * (sw(xs) - sw(xs - 1)) + sw(xs - 1)
End If
For j = 1 To xs - 1
dsj1(j) = Int(sj(j + 1) - sj(j))
dsj2(j) = (sj(j + 1) - sj(j) - dsj1(j)) * 100 / 60
dsj(j) = dsj1(j) + dsj2(j)
swpj(j) = (sw(j + 1) + sw(j)) / 2
mj(j) = dsj(j) * swpj(j)
a = a + mj(j)
Next j
End Sub
Public Sub daoru(sfile1 As String)
'****************** 选择要导入的文件
With Form1.CommonDialog1
.DialogTitle = "Open"
.CancelError = False
.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
.Filter = "All File (*.*)|*.*|文本文件 (*.txt)|*.txt"
.FilterIndex = 2
.ShowOpen
sfile1 = .filename
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -