原帖及讨论:http://bbs.bccn.net/thread-204225-1-1.html
QQ:535843194
自己做了一个图书管理系统,遇到很多问题,都项办法解决
现在教菜鸟一招,有新方法删除记录的也可以提供代码,大家互相学习
Private Sub cmdDelete_Click()
Dim int1 As Integer
int1 = List1.ListIndex ’int1 为删除项,即为list1.listindex,对应记录号
Open "info\bookNum.info" For Input As #6
Input #6, intCountOfBook ‘提取记录号
Close #6
If int1 > 0 Then ’如果不是第一项PS第一项为:图书编号 图书名称
Open "info\temp.txt" For Output As #5 ‘建立文本 准备记录删除后的信息
Close #5
Dim i As Integer
For i = 1 To int1 - 1 ’提取待删除前面的记录
Open "info\book.info" For Random As #1 Len = Len(book1)
Get #1, i, book1
Close #1
Open "info\temp.txt" For Random As #3 Len = Len(book1)
Put #3, i, book1
Close #3
Next i
For j = int1 + 1 To intCountOfBook ‘提取删除记录后的....
Open "info\book.info" For Random As #2 Len = Len(book1)
Get #2, j, book1
Close #2
Open "info\temp.txt" For Random As #4 Len = Len(book1)
Put #4, j - 1, book1 ‘!!!!注:此为j-1 记录号-1
Close #4
Next j
Kill "info\book.info" 删除原文本
Name "info\temp.txt" As "info\book.info" ’修改名称,注:.info为自创格式
Open "info\bookNum.info" For Output As #8 '''
Write #8, intCountOfBook - 1
Close #8
MsgBox "删除成功"
cmdRefurbish_Click ‘刷新list1
End If
End Sub
- 还没有人评论,欢迎说说您的想法!