下面的VB6.0编写的代码怎么转为VB.net
DimfilenameAsStringfilrname="c:\temp\MyTest.txt"DimGetDataAsString*5OpenfilenameForBi...
Dim filename As String
filrname = "c:\temp\MyTest.txt"
Dim GetData As String * 5
Open filename For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG=""" Then CMGs = i
If GetData = "[Host" Then DPBo = i - 2: Exit For
Next 展开
filrname = "c:\temp\MyTest.txt"
Dim GetData As String * 5
Open filename For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG=""" Then CMGs = i
If GetData = "[Host" Then DPBo = i - 2: Exit For
Next 展开
展开全部
Dim file1 As FileStream
filename = "c:\temp\MyTest.txt"
Dim GetData(4) As Byte, s(4) As Char
file1 = System.IO.File.OpenRead(filename)
Dim CMGs As Long
Dim DPBo As Long
Dim i As Integer = 0, j As Integer
While file1.Read(GetData, 0, 5) > 0
i = i + 1
For j = 0 To 4
s(j) = ChrW(GetData(j))
Next
If s = "CMG=""" Then CMGs = i
If s = "[Host" Then DPBo = i - 2 : Exit While
End While
主要是vb.net取消了定长字符串, 所以用字节数组读入, 还得转成字符数组来比较.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询