
怎样让vb程序下次运行时有上次的记录
4个回答
展开全部
建立文件来实现。给你一个程序代码参考参考
Option Explicit
Dim file_path As String
Dim file_name As String
Dim fileopen As Boolean
Dim have_open As Boolean
Dim haveselect As Boolean
Private Sub Command1_Click()
Dim str As String
CommonDialog1.MaxFileSize = 10240
CommonDialog1.ShowOpen
file_name = CommonDialog1.FileName
haveselect = True
End Sub
Private Sub Command2_Click()
Dim str As String
Dim path As String
Dim a As Integer
Dim text As String
Dim row As Integer
Dim findstr As String
text = RTrim(Text1.text)
text = LTrim(text)
If text = "" Then
MsgBox "请输入要查询的字符串", vbOKOnly, "提示"
Exit Sub
End If
If haveselect = True Then
GoTo nn
Else
MsgBox "请您打开要查询的文件", vbExclamation, "提示"
End If
nn:
If file_name <> "" Then
path = file_name
If have_open = True Then
MsgBox "文件已经打开", vbExclamation, ""
Else
Open path For Input As #1
have_open = True
Do While Not EOF(1)
Line Input #1, str
Debug.Print str
str = LTrim(str)
str = RTrim(str)
If str = text Then
row = row + 1
If Text2.text = "" Then
Text2.text = row
End If
End If
Loop
Close #1
Text3.text = row
End If
End If
haveopen: Exit Sub
End Sub
Private Sub Command3_Click()
End
If EOF(1) = True Then
Close #1
Exit Sub
End If
End Sub
Private Sub Form_Load()
haveselect = False
End Sub
Option Explicit
Dim file_path As String
Dim file_name As String
Dim fileopen As Boolean
Dim have_open As Boolean
Dim haveselect As Boolean
Private Sub Command1_Click()
Dim str As String
CommonDialog1.MaxFileSize = 10240
CommonDialog1.ShowOpen
file_name = CommonDialog1.FileName
haveselect = True
End Sub
Private Sub Command2_Click()
Dim str As String
Dim path As String
Dim a As Integer
Dim text As String
Dim row As Integer
Dim findstr As String
text = RTrim(Text1.text)
text = LTrim(text)
If text = "" Then
MsgBox "请输入要查询的字符串", vbOKOnly, "提示"
Exit Sub
End If
If haveselect = True Then
GoTo nn
Else
MsgBox "请您打开要查询的文件", vbExclamation, "提示"
End If
nn:
If file_name <> "" Then
path = file_name
If have_open = True Then
MsgBox "文件已经打开", vbExclamation, ""
Else
Open path For Input As #1
have_open = True
Do While Not EOF(1)
Line Input #1, str
Debug.Print str
str = LTrim(str)
str = RTrim(str)
If str = text Then
row = row + 1
If Text2.text = "" Then
Text2.text = row
End If
End If
Loop
Close #1
Text3.text = row
End If
End If
haveopen: Exit Sub
End Sub
Private Sub Command3_Click()
End
If EOF(1) = True Then
Close #1
Exit Sub
End If
End Sub
Private Sub Form_Load()
haveselect = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
每次结束程序时,保存text1的数据到数据库,下次运行程序时,首先去数据库提取数据。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.加一个config,然后让text1去撷取config的数据!
2.加一个数据库。
2.加一个数据库。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Form_Load()
Text1.Text = GetSetting(App.Title, "Text1", "Text", "")
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Text1", "Text", Text1.Text
End Sub
'...
Private Sub Form_Load()
Text1.Text = GetSetting(App.Title, "Text1", "Text", "")
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Text1", "Text", Text1.Text
End Sub
'...
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询