如何让用户在后台的txt文件中修改内容,工具可以实时调取并显示txt中修改后的内容
我制作了抽奖工具,已经打包成安装文件,安装包中已经添加了名为name.txt文件,意思是让用户按我的实例名单格式,在该文件里更改新的名单,然后再运行工具后,点“抽奖”按钮,文本框中刷新用户更改后的名单,可是我修改安装包里的name.txt文件名单后,工具里不能更新内容,我怀疑是路径设置的问题,还是将路径定位到安装包里的name.txt文件?请教高手,应该怎样解决?附代码:
Option Explicit
Dim xyr As Long
Dim ea As String
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Load()
Close #1
Open App.Path & "/name.txt" For Input As #1
Text2.Text = ""
Do While Not EOF(1)
Line Input #1, ea
Text2.Text = Text2.Text & vbCrLf & ea
Loop
Close #1
Text2.Text = Replace(Text2.Text, vbCrLf, "", 1, 1)
A = Split(Text2.Text, vbCrLf)
Text1.FontSize = 40
Text1.FontName = "楷体_gb2312"
Timer1.Enabled = False
Text2.Visible = False
End Sub
Private Sub Timer1_Timer()
Randomize
xyr = Int((UBound(A) + 1) * Rnd)
Text1.Text = A(xyr)
End Sub