Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Visual basic将数组整数(x)转换为单个字符的x数量_Vb.net_Arrays_Visual Studio_Integer - Fatal编程技术网

Vb.net Visual basic将数组整数(x)转换为单个字符的x数量

Vb.net Visual basic将数组整数(x)转换为单个字符的x数量,vb.net,arrays,visual-studio,integer,Vb.net,Arrays,Visual Studio,Integer,我的任务是创建一个Visual Basic控制台脚本,要求用户连续5次向数组中输入一个数字(以千为单位的销售数字),然后将这些结果显示为一种理货图 数据示例:销售额(10,7,12,5,15) 输出将是 2008:++++++++++ 2009:+++++++ 2010:++++++++++++ 2011:+++++ 2012:+++++++++++++++ 到目前为止,对于代码,我有: Module Module1 Sub Main() Dim sales(4) As I

我的任务是创建一个Visual Basic控制台脚本,要求用户连续5次向数组中输入一个数字(以千为单位的销售数字),然后将这些结果显示为一种理货图

数据示例:销售额(10,7,12,5,15) 输出将是

2008:++++++++++

2009:+++++++

2010:++++++++++++

2011:+++++

2012:+++++++++++++++
到目前为止,对于代码,我有:

Module Module1

Sub Main()

    Dim sales(4) As Integer
    Dim index As Integer
    Dim year As Integer


    For index = 0 To 4
        Console.Write("Enter your sales numbers (in thousands): ")
        sales(index) = Console.ReadLine()
    Next

    year = 2007

    For index = 0 To 4
        year = (year + 1)
---不确定这里的代码---


我只是不确定如何将数组中的整数值更改为单个字符的某个数字。

添加一个for来多次显示“-”就足够了吗

就像这样:

For index = 0 To 4
    year = (year + 1)
    Console.Write(year & ": ")

    ' Display as much "-" as there are sales
    For s = 1 to sales(index)
        Console.Write("-")
    Next s

    Console.WriteLine("") 'Next line
Next index

添加一个for来多次显示“-”就足够了吗

就像这样:

For index = 0 To 4
    year = (year + 1)
    Console.Write(year & ": ")

    ' Display as much "-" as there are sales
    For s = 1 to sales(index)
        Console.Write("-")
    Next s

    Console.WriteLine("") 'Next line
Next index

这仍然为我提供了额外的1,假设我输入了had sales(3,2,3,4,3)输出显示为4,3,4,5,4是的,我的错误,我开始了for..下一个在s=0时,我应该写“for s=1 to sales(index)”,而不是首先解决这个问题,你应该点击帮助你解决问题的答案旁边的复选框来接受答案。这仍然为我提供了1个额外的选项,比如我输入了had sales(3,2,3,4,3)。输出显示为4,3,4,5,4是的,我的错误,我开始了for。接下来在s=0时,我应该写“for s=1 to sales(index)”,而不是如果这个问题得到解决,您应该单击帮助您解决问题的答案旁边的复选框以接受答案。为什么不只是新字符串(“+”c,i)??因为我总是忘记构造函数重载;)为什么不仅仅是新字符串(“+”c,i)?因为我总是忘记构造函数重载;)
For Each i As Integer In Sales
    Console.WriteLine(New String("+"c, i))
Next i