回复 7楼 ccwu2
如页面上有四个留言栏,本人就做了如下复制,虽输入了四次内容,但只显示最后一个框的留言;(见图)
因为本人不会编程只会代码的DIY,所以不知错在何处?还请你指正;
[attach]66321[/attach][attach]66322[/attach]
Option Explicit 'ccwu2显示留言内容——1
Dim FN As String
Private Sub Command1_Click() 'ccwu2显示留言内容——2
If Text1.Text <> "" Then
Call outputData
Text1.Text = ""
End If
If Text2.Text <> "" Then
Call outputData
Text2.Text = ""
End If
If Text3.Text <> "" Then
Call outputData
Text3.Text = ""
End If
If Text4.Text <> "" Then
Call outputData
Text4.Text = ""
End If
End Sub
Private Sub outputData() 'ccwu2显示留言内容——3
Dim FileNum As Integer
FileNum = FreeFile
Open FN For Append As #FileNum
Print #FileNum, Text1.Text
Close #FileNum
FileNum = FreeFile
Open FN For Append As #FileNum
Print #FileNum, Text2.Text
Close #FileNum
FileNum = FreeFile
Open FN For Append As #FileNum
Print #FileNum, Text3.Text
Close #FileNum
FileNum = FreeFile
Open FN For Append As #FileNum
Print #FileNum, Text4.Text
Close #FileNum
End Sub
Private Function IsFileExist(strFileName As String) As Boolean 'ccwu2显示留言内容——3
Dim varFSO As Variant
Set varFSO = CreateObject("Scripting.FileSystemObject")
IsFileExist = varFSO.FileExists(strFileName)
Set varFSO = Nothing
End Function
Private Sub Form_Initialize() 'ccwu2显示留言内容——4
FN = App.Path & "\my1.txt"
FN = App.Path & "\my2.txt"
FN = App.Path & "\my3.txt"
FN = App.Path & "\my4.txt"
End Sub
Private Sub Form_Load() 'ccwu2显示留言内容——5
If IsFileExist(FN) = True Then
Call LoadData
End If
End Sub
Private Sub LoadData() 'ccwu2显示留言内容——6
Dim FileNum As Integer
Dim Temp As String
FileNum = FreeFile
Open FN For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, Temp
If Temp <> "" Then Text1.Text = Temp
Loop
Close #FileNum
FileNum = FreeFile
Open FN For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, Temp
If Temp <> "" Then Text2.Text = Temp
Loop
Close #FileNum
FileNum = FreeFile
Open FN For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, Temp
If Temp <> "" Then Text3.Text = Temp
Loop
Close #FileNum
FileNum = FreeFile
Open FN For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, Temp
If Temp <> "" Then Text4.Text = Temp
Loop
Close #FileNum
End Sub
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
[
本帖最后由 jrs123 于 2012-11-15 20:07 编辑 ]