首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

用VB中文件读写操作示例相关代码.菜鸟!用

2012-01-24 
用VB中文件读写操作示例相关代码.........初学者!急用我要临时用VB做点东西文件操作用起来老不顺,有哪位大

用VB中文件读写操作示例相关代码.........初学者!急用
我要临时用VB做点东西文件操作用起来老不顺,有哪位大哥有保存过相关的代码,越
基础越简单越好!

[解决办法]
Dim i As Integer
Public head(30) As Long

Private Sub Command1_Click()
CommonDialog1.InitDir = "d:\ "
CommonDialog1.ShowOpen
Dim b As Variant
fileno = FreeFile
b = CommonDialog1.FileName
Open b For Binary As fileno
For i = 0 To 30
Get fileno, , head(i)
Next
Close fileno
Text1.Text = head(0)
End Sub


[解决办法]
另存为FRM1.FRM


VERSION 5.00
Begin VB.Form Form1
Caption = "我的通讯录 "
ClientHeight = 2985
ClientLeft = 60
ClientTop = 345
ClientWidth = 8235
LinkTopic = "Form1 "
ScaleHeight = 2985
ScaleWidth = 8235
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Caption = "提示信息: "
Height = 495
Left = 120
TabIndex = 13
Top = 2400
Width = 8055
Begin VB.Label LabMsg
Height = 240
Left = 480
TabIndex = 14
Top = 200
Width = 7095
End
End
Begin VB.CommandButton cmdAdd
Caption = "增加 "
Height = 495
Left = 2400
TabIndex = 12
Top = 1800
Width = 1215
End
Begin VB.CommandButton cmdRef
Caption = "修改 "
Height = 495
Left = 6240
TabIndex = 11
Top = 1800
Width = 1215
End
Begin VB.CommandButton cmdDel
Caption = "删除 "
Height = 495
Left = 4320
TabIndex = 10
Top = 1800
Width = 1215
End
Begin VB.CommandButton cmdQury
Caption = "查询 "
Height = 495
Left = 600
TabIndex = 9
Top = 1800
Width = 1215
End
Begin VB.Frame Frame1
Caption = "人员信息: "
Height = 1455
Left = 120
TabIndex = 0
Top = 120
Width = 7935
Begin VB.TextBox TxtArr
Appearance = 0 'Flat
Height = 375
Index = 3
Left = 3960
TabIndex = 8
Top = 840
Width = 3855
End
Begin VB.TextBox TxtArr
Appearance = 0 'Flat
Height = 375
Index = 2
Left = 840
TabIndex = 5
Top = 840
Width = 2415
End
Begin VB.TextBox TxtArr
Appearance = 0 'Flat
Height = 375
Index = 1
Left = 2760
TabIndex = 3
Top = 240


Width = 5055
End
Begin VB.TextBox TxtArr
Appearance = 0 'Flat
Height = 375
Index = 0
Left = 840
TabIndex = 2
Top = 240
Width = 1095
End
Begin VB.Label Label4
Caption = "公司: "
Height = 375
Left = 3360
TabIndex = 7
Top = 960
Width = 735
End
Begin VB.Label Label3
Caption = "电话: "
Height = 375
Left = 240
TabIndex = 6
Top = 960
Width = 1215
End
Begin VB.Label Label2
Caption = "住址: "
Height = 255
Left = 2160
TabIndex = 4
Top = 360
Width = 735
End
Begin VB.Label Label1
Caption = "姓名: "
Height = 255
Left = 240
TabIndex = 1
Top = 360
Width = 495
End
End
End
Attribute VB_Name = "Form1 "
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
[解决办法]
tmpstr = "无可厚非 "
Open "D:\datarecord.txt " For append lock Read As #1 '追加 锁定
Print #1, tmpstr
Close #1

[解决办法]
同意楼上

热点排行