求助:用vb來實現對GPIB卡的控制
Option Explicit Private Type recordtype
name As String * 8
tel_number As String * 8
post_code As String * 6
End Type
Dim person As recordtype
Dim filenum As Integer
Dim reclength As Long, recnum As Long
Private Sub cmdopen_click()
Reset
filenum = FreeFile
reclength = Len(person)
Open "address" For Random As filenum Len = reclength
recnum = LOF(filenum) \ reclength + 1
txtnum.Text = Str(recnum)
txtname.SetFocus
End Sub
Private Sub cmdput_click()
If txtname <> "" And txttel <> "" And txtpost <> "" Then
person.name = txtname.Text
person.tel_number = txttel.Text
person.post_code = txtpost.Text
Put #filenum, recnum, person
txtname.Text = ""
txttel.Text = ""
txtpost.Text = ""
recnum = recnum + 1
txtnum.Text = Str(recnum)
Else
txtnum.Text = "输入数据错,重新输入"
End If
End Sub
Private Sub cmdread_click()
Dim choice As Integer
recnum = Str(InputBox("输入记录号"))
Seek #filenum, recnum
Do While Not EOF(filenum)
txtnum.Text = Str(recnum)
Get #filenum, recnum, person
txtname.Text = person.name
txttel.Text = person.tel_number
txtpost.Text = person.post_code
choice = MsgBox("继续查看?", vbYesNo)
If choice = vbNo Then
Exit Do
End If
recnum = recnum + 1
Loop
End Sub
Private Sub cmderase_click()
Dim filenum1 As Integer, readnum As Long
Dim writenum As Long, erasenum As Long
filenum1 = FreeFile
Open "tempfile" For Random As #filenum1 Len = reclength
Label4.Caption = "删除记录号"
erasenum = Val(InputBox("输入删除记录号"))
Do While Not EOF(filenum)
readnum = readnum + 1
Get #filenum, readnum, person
If readnum <> erasenum Then
writenum = writenum + 1
Put #filenum1, writenum, person
End If
Loop
Close #filenum
Kill "address"
Close #filenum1
Name "tempfile" As "address"
txtnum.Text = Str(erasenum) & "号记录已被删除"
End Sub
Private Sub cmdend_click()
Close #filenum
End
End Sub