7,766
社区成员
发帖
与我相关
我的任务
分享
Dim intConfigFileLen As Integer: intConfigFileLen = 3000
Dim byteConfig() As Byte
ReDim byteConfig(1 To intConfigFileLen)
Dim i As Integer: i = 0
Open strConfigFolder & strConfigFilename For Binary As #1
Do While Not EOF(1)
i = i + 1
If i > intConfigFileLen Then GoTo FAIL
Get #1, , byteConfig(i)
Loop
MSComm1.Output = byteConfig
Close #1
Private Sub Command1_Click()
CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "All Files (*.*)|*.*|"
' 指定缺省的过滤器
'CommonDialog1.FilterIndex = 2
' 显示“打开”对话框
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Binary As #1
MsgBox LOF(1)
Close
End Sub
Option Explicit
Dim data As Variant
Dim Temp1 As String
Dim m As Integer
Dim strData As String
Dim bytInput() As Byte
Dim sj() As Byte
Dim i As Integer
Dim j As Integer
Dim sTemp As String
Dim yTemp() As Byte
Dim Hsum As Integer
Dim Ulen As Long
Dim Llen As Long
Dim for_Sum As Long
Dim Yu_sum As Integer
Dim strfFleName As String
Private Sub cmdSend_Click()
Dim strData As String
Dim str1 As String
Dim NextLine As String
Dim Txt_sj As String
CommonDialog1.ShowOpen
Text1 = ""
strfFleName = CommonDialog1.FileName
Open strfFleName For Input As #1
Do While Not EOF(1)
Input #1, str1
sTemp = sTemp & str1 & Chr(13) & Chr(10)
Loop
Close
Text1 = sTemp
Text1.Refresh
yTemp = StrConv(sTemp, vbFromUnicode)
Hsum = UBound(yTemp)
Text2 = Hsum
Text2.Refresh
yTemp = StrConv(sTemp, vbFromUnicode)
Hsum = UBound(yTemp)
Text2 = Hsum + 1
Ulen = 128
Llen = 0
Yu_sum = (Hsum + 1) Mod Ulen
for_Sum = (Hsum + 1) \ Ulen
Print "字节长= "; Hsum + 1; "循环次数= "; for_Sum; "余数= "; Yu_sum
DoEvents
ReDim sj(Ulen - 1)
Text7 = Timer
Text7.Refresh
If (Hsum + 1) Mod Ulen = 0 Then
For i = 0 To Ulen - 1
sj(i) = yTemp(i + Ulen * j)
If i >= Ulen Then
Exit For
End If
Next i
MSComm1.Output = sj
ElseIf (Hsum + 1) Mod Ulen <> 0 Then
For j = 0 To for_Sum - 1
For i = 0 To Ulen - 1
sj(i) = yTemp(i + Ulen * j)
If i >= Ulen Then
Exit For
End If
Next i
MSComm1.Output = sj
Next j
ReDim sj(Yu_sum - 1)
For i = 0 To Yu_sum - 1
sj(i) = yTemp(i + Ulen * for_Sum)
Next
MSComm1.Output = sj
ElseIf (Hsum + 1) < Ulen Then
MSComm1.Output = yTemp
End If
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.InBufferSize = 1024
MSComm1.OutBufferSize = 512
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text7 = ""
End Sub