DO循环,直到反转。狡猾 [英] DO Loop Until Reverse. Tricky

查看:111
本文介绍了DO循环,直到反转。狡猾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建显示的行数和列一个表,并用下划线的DO WHILE功能。我应该使用DO循环,直到功能。我无法做它在DO循环,直到功能。任何帮助将大大AP preciated。

暗淡outSideCounter作为整数 昏暗inSideCounter作为整数 outSideCounter = 0 inSideCounter = 0 做,而outSideCounter< = 4     '36下划线     lblDisplayTable.Text = lblDisplayTable.Text和放大器; ________________&放大器; VBCR和放大器; VBCR     outSideCounter = outSideCounter + 1     做,而inSideCounter< = 4         inSideCounter = inSideCounter + 1         lblDisplayTable.Text = lblDisplayTable.Text和放大器; COL#&放大器; inSideCounter和放大器;     循环     inSideCounter = 0     lblDisplayTable.Text = lblDisplayTable.Text和放大器; VBCR

解决方案

的差别做的,而做循环,直到的是,前者始终执行检查的的做功,而后者则一个工作单元和然后的做检查。所以,你会使用到的语句时,你知道已经有一些工作要做,要保存的检查后。

还要注意的是的病情变化的含义。在使用的情况下,,而,您的继续的到,只要条件为真做的工作。在的情况下,直到,你的停止的做功时的条件为真。所以,条件将是不同的两者之间的变化,以获得相同的结果。由于评论者@Strilanc指出了这一点。

I have created a table displaying rows and columns of Numbers and underscores using the DO WHILE function. I was supposed to use the DO Loop Until function. I am having trouble doing it in the DO Loop Until function. Any help would be greatly appreciated.

Dim outSideCounter As Integer
Dim inSideCounter As Integer

outSideCounter = 0
inSideCounter = 0

Do While outSideCounter <= 4
    '36 underscores
    lblDisplayTable.Text = lblDisplayTable.Text & "________________" & vbCr & vbCr
    outSideCounter = outSideCounter + 1

    Do While inSideCounter <= 4
        inSideCounter = inSideCounter + 1
        lblDisplayTable.Text = lblDisplayTable.Text & "col #" & inSideCounter & "     "
    Loop
    inSideCounter = 0
    lblDisplayTable.Text = lblDisplayTable.Text & vbCr

解决方案

The difference between do while and do loop until is that the former always performs the check before doing work, and the latter does one unit of work and then does the check. So, you would use the until statement when you know there is already some work to do and want to save the check for later.

Also note that the meaning of the condition changes. In the case of using while, you're continuing to do work as long as the condition is true. In the case of until, you'll stop doing work when the condition is true. So, the condition will be different between the two variations to get the same result. Thanks to commenter @Strilanc for pointing that out.

这篇关于DO循环,直到反转。狡猾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆