这是我使用visual studio .NET 2015进行基础编程的第四周,我遇到了这个问题。 [英] This is my 4th week in basic programming using visual studio .NET 2015 and I am stuck with this problem.

查看:70
本文介绍了这是我使用visual studio .NET 2015进行基础编程的第四周,我遇到了这个问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于此编码练习:



打开VB2015 \Chap06 \MultiplicationSolution(MultiplicationSolution.sln)文件。

代码应用程序显示类似于图6-31(Zak,2016)所示的乘法表。 (在GUI中;有一个数字:带有txt.Number,三个按钮标记为:For ... Next,Do ... Loop,和Exit,然后有乘法表:使用lblTable,其中数字应该是显示如下所述。)

使用btnForNext_Click过程中的For ... Next语句,并在btnDoLoop_Click过程中使用Do ... Loop语句。适当地测试应用程序。



我可以得到如下数字:



* 1 =

* 2 =

* 3 =

(依此类推)



什么我试过了:



For this coding exercise:

Open the VB2015\Chap06\MultiplicationSolution(MultiplicationSolution.sln) file.
Code the application to display a multiplication table similar to the one shown in Figure 6-31 (Zak, 2016). (In the GUI; There is a Number: with the txt.Number, Three buttons labeled as: For...Next, Do...Loop, and Exit, then there is the Multiplication table: with lblTable where the numbers are supposed to be displayed like I described below.)
Use the For...Next statement in the btnForNext_Click procedure, and use the Do...Loop statement in the btnDoLoop_Click procedure. Test the application appropriately.

I can get the numbers to display as follow:

* 1 =
* 2 =
* 3 =
(and so on)

What I have tried:

Public Class frmMain
    Dim NumToMultiply As Integer = 1

    Private Sub btnDoLoop_Click(sender As Object, e As EventArgs) Handles 
    btnDoLoop.Click
        ' displays a multiplication table

        Do Until NumToMultiply >= 9
            lblTable.Text = lblTable.Text & " * " & NumToMultiply & " = " & 
            ControlChars.NewLine
            NumToMultiply += 1
        Loop
    End Sub

    Private Sub btnForNext_Click(sender As Object, e As EventArgs) Handles 
    btnForNext.Click
        ' displays a multiplication table

        For NumToMultiply As Integer = 1 To 9
            lblTable.Text = lblTable.Text & " * " & NumToMultiply & " = " & 
            ControlChars.NewLine
            NumToMultiply += 1
        Next
    End Sub

推荐答案

Quote:

编写应用程序代码以显示类似于图6-31所示的乘法表(Zak,2016 )。

Code the application to display a multiplication table similar to the one shown in Figure 6-31 (Zak, 2016).



我们看不到这个数字。


We can't see the figure.

引用:

数字应该像我在下面描述的那样显示。

the numbers are supposed to be displayed like I described below.



我们没有任何描述。

我们无法帮助你,因为我们只是没有任何有用的信息。你是唯一可以帮助你的人。学习如何使用调试器,它会告诉你代码在做什么。



有一个工具可以让你看到你的代码在做什么,它的名字是调试器。它也是一个很好的学习工具,因为它向你展示了现实,你可以看到哪种期望与现实相符。

当你不明白你的代码在做什么或为什么它做它做的时候,答案就是答案是调试器

使用调试器查看代码正在执行的操作。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量。



调试器 - 维基百科,免费的百科全书 [ ^ ]



掌握Visual Studio 2010中的调试 - 初学者指南 [ ^ ]

使用Visual Studio 2010进行基本调试 - YouTube [ ^ ]

Visual Basic / Visual Studio视频导师ial - 基本调试 - YouTube [ ^ ]

初学者的Visual Basic .NET编程 - 断点和调试工具 [ ^ ]

调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。

调试器中没有魔法,它没有发现错误,它只是帮助你到。当代码没有达到预期效果时,你就接近了一个bug。


We don't have any description.
We can't help you because we just don't have any usable information. You are the only one that can help you. Learn how to use the debugger, it will show you what your code is doing.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
Visual Basic / Visual Studio Video Tutorial - Basic Debugging - YouTube[^]
Visual Basic .NET programming for Beginners - Breakpoints and Debugging Tools[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


删除这一行:

Remove this line:
NumToMultiply += 1



因为For ... Next是迭代器(增量)。


As the For ... Next is the iterator (incremental).


这篇关于这是我使用visual studio .NET 2015进行基础编程的第四周,我遇到了这个问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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