【问题标题】:amout of write line instaces vary depending on YVAL variable写入行实例的数量取决于 VALUE 变量
【发布时间】:2010-11-30 14:32:10
【问题描述】:

我有一个可以是任何随机值的测量值,只是为了好玩,我需要将 2440 毫米除以 610 毫米的行业标准,即 2440 / 610 = 4

以编程方式编写 NEWVAL = YVAL / STDVAL

NEWVAL (4) 让我参考我想在 txt 文件中添加新行的实例数 我知道我希望第一行说 0,0,0 而第二行说 0,610,0第三个 0,1220,0 第四个 0,1830,0 和最后一个 0,2440,0,尽管这很容易通过添加来实现,如果YVAL 是用户定义的。

简单地说,如果 YVAL 变量在 4880mm 处的长度是双倍的,那么一半会丢失

【问题讨论】:

  • 不会使长度 4880mm 使 NEWVAL = 8?这一半怎么样?

标签: vb.net variables console.writeline


【解决方案1】:

你的意思是这样的?

    Dim YVAL = 2440                                     ''Measurement
    Dim STDVAL = 610                                    ''Standard value
    Dim NEWVAL = YVAL \ STDVAL                          ''Force integer division
    For I = 0 To YVAL Step STDVAL                       ''Loop through each item
        Trace.WriteLine(String.Format("0,{0},0", I))    ''Output
    Next

【讨论】:

    猜你喜欢
    • 2022-10-23
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    • 2014-08-20
    • 2015-03-23
    • 2021-11-03
    • 2018-04-07
    相关资源
    最近更新 更多