注册 登录
编程论坛 VB6论坛

求助:用vb來實現對GPIB卡的控制

chenghui82 发布于 2006-12-17 05:52, 1917 次点击
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
8 回复
#2
chenghui822006-12-17 07:08
上面的關於GPIB的發錯了
recnum = LOF(filenum) \ reclength + 1
這句是甚麼意思啊
#3
purana2006-12-17 08:00
好像只是对文件进行保存而已....没有看到哪里实现了对GPIB卡的控制...

...这是对文件中的记录总数..
#4
londgn2006-12-19 14:52
给我个邮箱,我发个例子程序给你,用的是研华的GPIB卡,去控制一个检测设备的.
#5
chenghui822006-12-19 23:14
londgn兄弟:
太好了,小弟我在這先謝謝了!
我的邮箱是:chenghui82@163.com
#6
清澂居士2006-12-19 23:42
還真是第一次聽說過這個東西`````不知道鉨用這個做什么呢 ?
#7
yangzhli2006-12-23 21:14
如果用GPIB卡是为了控制仪表,可到Agilent公司的网站上下载driver,软件是免费的,driver的名字是Agilent IO Libraries,编程时只需将visa32。bas模块添加到你的工程中即可使用。
#8
nick31667342011-10-31 22:47
以下是引用londgn在2006-12-19 14:52:37的发言:

给我个邮箱,我发个例子程序给你,用的是研华的GPIB卡,去控制一个检测设备的.
你好,能否也给我发一个例子?
我的邮箱为:378559432@
非常感谢!
#9
赵辉5112012-12-31 09:59
以下是引用londgn在2006-12-19 14:52:37的发言:

给我个邮箱,我发个例子程序给你,用的是研华的GPIB卡,去控制一个检测设备的.
这位大哥,给小弟一份呗,469489919@
感激不尽啊!!!
1