
----------------------------------------------------- 补充1
这个问题不难解决,在读数据的时候,需要多读一点,但是下次再读取的时候,不能仅接着中猛厅上次的尾部读取了,而是应该倒退几个字符,倒退的数目应该是:最大特征字符长度 - 1。
下面是个简单的图解:
------------------|xxx 3 xxx|
---------|xxx 2 xxx|
|xxx 1 xxx|
################################################
一次性的new出一个特别巨大的内存,是一个愚蠢的做法,如果是一个大于4G的文件,那么你就会更加困难。虽然系统会自动的申请虚拟内存,知闭但是这将极大的影响函数处理的速度,这也是我们国家软件行业所存在的通病,虽然很多程序也能够运行,但是效率与速度都相当的落后,我们应该卖隐把软件做的尽可能的快、智能、便捷、清丽。
'文本框的HideSelection属性设为FalsePrivate Sub Command1_Click()
Dim strTxt$
CommonDialog1.Filter = "团余文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <>"" Then
Open CommonDialog1.FileName For Input Access Read As #1
Do While Not EOF(1)
Line Input #1, strTxt
Text1.Text = Text1.Text &strTxt &vbCrLf
Loop
Close #1
End If
End Sub
Private Sub Command2_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt|所纯塌有文件(*.*)|*.*"
CommonDialog1.ShowSave
If CommonDialog1.FileName <>"" Then
Open CommonDialog1.FileName For Output As #1
Print #1, Text1.Text
Close #1
End If
End Sub
Private Sub Command3_Click()
Dim pos As Long
Dim CurrentPosition As Long
Dim SearchStr As String
If Text1.SelText <>"" Then
CurrentPosition = Text1.SelStart + 2
SearchStr = Text1.SelText
Else
CurrentPosition = Text1.SelStart + 1
SearchStr = InputBox("查找")
End If
pos = InStr(CurrentPosition, Text1.Text, SearchStr)
If pos <>0 Then
Text1.SelStart = pos - 1
Text1.SelLength = Len(SearchStr)
Else
MsgBox "找不到:" &SearchStr
End If
End Sub
Private Sub Command4_Click()
On Error GoTo 1
CommonDialog1.CancelError = True
CommonDialog1.Flags = &H3 Or &H100
CommonDialog1.ShowFont
Text1.Font.Name = CommonDialog1.FontName
Text1.Font.Size = CommonDialog1.FontSize
'''''''''''''塌裤滚
1
End Sub
我试了下没有颂胡问题,只要在cmd下找到你的exe文件所在的路径,然后输入 可执行文件名 filemame.txt
回车后,随便输入,。。。@。。。散此,显冲樱迅示@之前内容,之后没有。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)