VB中Do while 嵌套使用,编译时提示,Loop找不到Do

这个程序的目的是通过串口,下载MCU中的一个数组内的数据,并保存到电脑上

Private Sub CommandDownload_Click()
Dim ByteReceiveData() As Byte
Dim Frame(1) As String
Dim i As Integer

Dim SaveFileId As Integer
Dim FileCount As Integer
Dim StrFileName As String

Dim RecDataCount As Long
Dim RecStart(0) As Byte
Dim DownLoadOk As Boolean

RecStart(0) = 5
RecDataCount = 0
FileCount = 0
SaveFileId = FreeFile()
DownLoadOk = False

StrFileName = App.Path + "\" + "温度数据" + CStr(FileCount) + ".txt"

Do While Dir(StrFileName) <> ""
FileCount = FileCount + 1
StrFileName = App.Path + "\" + "温度数据" + CStr(FileCount) + ".txt"
Loop

Do While (RecDataCount < 90)

MSComm.Output = RecStart()

Do While MSComm.CommEvent = comEvReceive
ByteReceiveData() = MSComm.Input
For i = 0 To 1
Frame(i) = ByteReceiveData(i)
If Len(Hex(Frame(i))) = 1 Then
Frame(i) = "0" + Hex(Frame(i))
Else
Frame(i) = Hex(Frame(i))
End If

Open StrFileName For Append As #SaveFileId
Print #SaveFileId, Now & "," & ByteReceiveData(0) & "," & ByteReceiveData(1)
Close #SaveFileId

Loop ‘此行出现问题
RecDataCount = RecDataCount + 2
Loop
MsgBox "数据下载完成!", vbOKOnly + vbInformation, "提示信息!"

End Sub

论代码对齐的重要性。。。

FOR 少了 next

    Do While (RecDataCount < 90)
        MSComm.Output = RecStart()
        Do While MSComm.CommEvent = comEvReceive
            ByteReceiveData() = MSComm.Input
            For i = 0 To 1
                Frame(i) = ByteReceiveData(i)
                If Len(Hex(Frame(i))) = 1 Then
                    Frame(i) = "0" + Hex(Frame(i))
                Else
                    Frame(i) = Hex(Frame(i))
                End If
                Open StrFileName For Append As #SaveFileId
                    Print #SaveFileId, Now & "," & ByteReceiveData(0) & "," & ByteReceiveData(1)
                Close #SaveFileId
            NEXT   '这里少了
        Loop
        RecDataCount = RecDataCount + 2
    Loop

温馨提示:内容为网友见解,仅供参考
无其他回答

VB中Do while 嵌套使用,编译时提示,Loop找不到Do
论代码对齐的重要性。。。FOR 少了 next Do While (RecDataCount < 90) MSComm.Output = RecStart() Do While MSComm.CommEvent = comEvReceive ByteReceiveData() = MSComm.Input For i = 0 To 1 Frame(i) = ByteReceiveData(i) If Len(Hex(Frame(i))) = 1 Then ...

VB 大家帮忙分析下,为什么运行的时候说 loop 缺少 DO
Loop Close #1 End If 最后四句改成 Print lestline End If Loop Close #1

为什么我的程序总提示loop 没有do
end if 写在loop前面,或者loop写在end if后面。你这么写不是嵌套。VB之所以给你提示Loop缺少Do而不是提示你If缺少End If是因为当它检查到If块时,首先发现这个块里出现了Loop,但是却没有Do,于是不再继续向下检查而直接返回错误信息了.可能和人的习惯不太一样.要适应VB的这种无厘头....

VB提示LOOP没有do
Sub 生长XX()Dim SA%, XB%SA = 1Do While Sheet1.Cells(SA, 3) <> "" If Sheet1.Cells(SA, 5) < Sheet2.Cells(32, 1) Then XB = IIf(Sheet1.Cells(SA, 2) = "男", 3, 4) Sheet1.Cells(SA, 8) = IIf(Sheet1.Cells(SA, 3) <= Sheet2.Cells(31, XB), ...

VB编译错误 loop 没有 DO 什么意思?
请参考对"qbasic的语言设计有哪几种?"问题的回答,其中涉及DO LOOP语句的用法.你应在VB编程窗口的提示下找到调试黄色标注代码处仔细看DO LOOP结构的语法错误.或把出错部分代码上传便于分析.网址:祝成功

《vb求助》 Loop 缺少 Do
If x = "##" Then Exit Do end if 或者:If x = "##" Then Exit Do

vb在运行过程中出现 loop 找不到 do 是什么原因?
i) Then Min = Jacobief(i)End If Next i If Min < preci Then Exit Do Else noe(i) = noe(i) + Jacobief(2 * i - 1)nof(i) = nof(i) + Jacobief(2 * i)k = k + 1 End If ‘\/\/\/你就这里的问题\/\/\/ Loop While k < 100 End Sub ...

VB6.0 为什么 Loop 缺少 Do?
Private Sub Form_click()Dim a() As Integer, i As Integer, max As Integer, min As Integer, sum As Integer, average As Integer, maxi As Integer, mini As Integer i = 0 sum = 0 Do While a(i) <> -1 a(i) = Val(InputBox("请输入该同学的成绩(请输入整数)"))max = ...

在VB程序中Do While Loop问题
循环的执行步骤:首先判断,当满足while后面的表达时,执行do。。。loop之间的代码,执行完毕,再次判断,满足继续do...loop,不满足,则结束do循环。那么,本题首先判断y>4 由于y=4并不大于4,y>4为假,跳过do...loop循环,执行print x x=1 所以显示为1,选A 你选B,如果是do……loop while...

关于vbs do while...loop 的问题
vb里确实不太行 因为按行执行 loop重复出现 所以无法循环 建议使用for next (标记)循环 有区别的标记 可以循环嵌套 或者是while和for嵌套 或者是while和do loop的嵌套 一般for循环是比较好的

相似回答
大家正在搜