📄 frmform.frm
字号:
VERSION 5.00
Begin VB.Form frmForm
Caption = "Fig. 14.20: Credit Inquiry Program"
ClientHeight = 1785
ClientLeft = 2460
ClientTop = 2745
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 1785
ScaleWidth = 4680
Begin VB.CommandButton cmdButton
Caption = "Zero Balances"
Height = 345
Index = 2
Left = 3225
TabIndex = 3
Top = 1350
Width = 1335
End
Begin VB.CommandButton cmdButton
Caption = "Debit Balances"
Height = 345
Index = 1
Left = 1665
TabIndex = 2
Top = 1350
Width = 1335
End
Begin VB.CommandButton cmdButton
Caption = "Credit Balances"
Height = 345
Index = 0
Left = 105
TabIndex = 1
Top = 1350
Width = 1335
End
Begin VB.TextBox txtDisplay
Height = 1170
Left = 135
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
TabStop = 0 'False
Top = 105
Width = 4425
End
End
Attribute VB_Name = "frmForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 14.20
' Credit inquiry program
Option Explicit ' General declaration
Dim mFso As New FileSystemObject ' General declaration
Dim mType As Integer ' General declaration
Const mCREDIT = 0, mDEBIT = 1, mZERO = 2 ' General declaration
Private Sub cmdButton_Click(Index As Integer)
mType = Index ' Assign cmdButton control array index
Call openAndReadFile ' Open and read file
End Sub
Private Sub openAndReadFile()
Dim txtStream As TextStream, s As String
Dim balance As Currency, pos As Long
txtDisplay.Text = "Accounts:"
' Get "clients.dat" and open a TextStream for reading
Set txtStream = mFso.GetFile("c:\clients.dat"). _
OpenAsTextStream(ForReading)
' Loop until end of stream is found
Do
s = txtStream.ReadLine ' Read one line
' Find the position of the second space
pos = InStr(InStr(1, s, " ", vbTextCompare) + 1, s, " ", _
vbTextCompare)
' Extract the String that contains the balance
balance = Trim$(Mid$(s, pos, Len(s) - pos))
' Determine what if anything should be displayed
If (mType = mCREDIT And balance < 0) Then
txtDisplay.Text = txtDisplay.Text & vbNewLine & s
ElseIf (mType = mDEBIT And balance > 0) Then
txtDisplay.Text = txtDisplay.Text & vbNewLine & s
ElseIf (mType = mZERO And balance = 0) Then
txtDisplay.Text = txtDisplay.Text & vbNewLine & s
End If
Loop While (txtStream.AtEndOfStream = False)
Call txtStream.Close ' Close TextStream
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -