NotReady(No)近来领分~~~

dragonhell 2003-10-20 09:11:19
Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False

aa中存放的就的是那个文件Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False


aa中存放的就是每一行的数据!
dim i as integer
dim str as string
dim lngtemp as long
dim lngCount1 as long
dim strTmp as string
i=0
dim strVal as string
for lngtmp=lbound(aa) to ubound(aa)
if i mod 10<>0 then
i=i+1
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
else
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
str=str & vbCrLf
end if
next lngtmp
msgbox str
str中存的就是那个信息!


能不能再详细解释一下?感激不尽!
(ZJ)
52368
53698
52145
53X69
58631
。。。
。。。
。。。
。。。
53674
这样的报文,
最后要写个函数,跳过(ZJ)这一行,显示文本如下:
52368 53698 52145 53/69 53684 。。。 。。。 。。。 。。。
53674=
一行不超过10个数,
在最后一个数后加个=
遇到X显示为/
该如何编写???
...全文
62 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
射天狼 2003-10-21
  • 打赏
  • 举报
回复
晕,这么长~~
NotReady 2003-10-21
  • 打赏
  • 举报
回复
改成这样更合理!
Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False

aa中存放的就的是那个文件Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False


aa中存放的就是每一行的数据!
dim i as integer
dim str as string
dim lngtemp as long
dim lngCount1 as long
dim strTmp as string
dim strVal as string
for lngtmp=lbound(aa) to ubound(aa)
i=0
if i mod 10<>0 then
if i=0 and str<>"" then str=str & vbCrLf
i=i+1
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
else
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
end if
next lngtmp
如果要显示"=",只要加下面代码就行了!
str=str & "="
msgbox str
str中存的就是那个信息!


这样就行了!你试试看!
NotReady 2003-10-21
  • 打赏
  • 举报
回复
Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False

aa中存放的就的是那个文件Dim lngTmp As Long
Dim strFile As String
Dim aa() As String
On Error GoTo PROC_ERR
lngTmp = FreeFile()
Open strPath For Binary Access Read As #lngTmp
strFile = CStr(Input(LOF(lngTmp), #lngTmp))
Close #lngTmp
aa = Split(strFile, Chr(13))
lngLine = UBound(aa)
GetFileLine = True
Exit Function
PROC_ERR:
GetFileLine = False


aa中存放的就是每一行的数据!
dim i as integer
dim str as string
dim lngtemp as long
dim lngCount1 as long
dim strTmp as string
i=0
dim strVal as string
for lngtmp=lbound(aa) to ubound(aa)
if i mod 10<>0 then
i=i+1
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
else
strval=trim(aa(lngtmp))
for lngtemp=1 to len(trim(aa(lngtmp)))
strtmp=left(strval,1)
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
strval=mid(strval,2,len(strval)-1)
next lngtemp
str=str & vbCrLf
end if
next lngtmp
如果要显示"=",只要加下面代码就行了!
str=str & "="
msgbox str
str中存的就是那个信息!
NotReady 2003-10-21
  • 打赏
  • 举报
回复
if strtmp="x" then
str=str & "/"
else
str=str & strtmp
end if
这段代码不就是控制如果字符串中有x就显示为"/",难道不行吗,
还有第一个if是用来控制换行的
coolboy0000love 2003-10-21
  • 打赏
  • 举报
回复
楼上不错
不过,其实在读文本的时候只要把它读出来直接赋予一个字符串就可以
rainstormmaster 2003-10-20
  • 打赏
  • 举报
回复
Text1要设为多行
rainstormmaster 2003-10-20
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim i As Long
Dim filename As String
Dim buff() As Byte
filename = "d:\mc\mcctest123.txt"
i = FileLen(filename)
ReDim buff(i - 1)
Open filename For Binary As #1
Get #1, , buff
Close #1
Dim s As String, outs As String
s = StrConv(buff, vbUnicode)
Dim arr As Variant
arr = Split(s, vbCrLf)
For i = 0 To UBound(arr)
arr(i) = Trim(arr(i))
Next
Dim temp As String, outstr As String
For i = 1 To UBound(arr) - 1
If i Mod 10 = 0 Then
temp = vbCrLf
Else
temp = " "
End If
outstr = outstr + arr(i) + temp
Next
outstr = Trim(outstr)
outstr = outstr + vbCrLf + arr(UBound(arr)) + "="
outstr = Replace(outstr, "x", "/")
Text1.Text = outstr


End Sub

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧