7,763
社区成员
发帖
与我相关
我的任务
分享
Dim oRs As New Recordset
Dim sLine As String
'保存
Private Sub Command1_Click()
oRs.MoveFirst
Open "l:\tmp1.txt" For Output As #1
Print #1, oRs.GetString(adClipString, , vbTab, vbCrLf, "")
Close #1
End Sub
'添加
Private Sub Command2_Click()
oRs.AddNew
End Sub
'删除
Private Sub Command3_Click()
oRs.Delete adAffectCurrent
End Sub
'修改
Private Sub DataGrid1_Change()
If DataGrid1.Text = "" Then DataGrid1.Text = "null"
End Sub
Private Sub Form_Load()
oRs.Fields.Append "fd1", adBSTR
oRs.Fields.Append "fd2", adBSTR
oRs.Open
loadtxt
End Sub
'读入
Private Function loadtxt()
Open "l:\tmp.txt" For Input As #1
While Not EOF(1)
oRs.AddNew
Line Input #1, sLine
oRs!fd1 = Split(sLine, vbTab)(0)
oRs!fd2 = Split(sLine, vbTab)(1)
Wend
Close #1
Set DataGrid1.DataSource = oRs
End Function
Private Sub Form_Unload(Cancel As Integer)
Set oRs = Nothing
End Sub