2017-03-16 25 views
0

如果我把console.writeline(sale)放在那里,那么我需要在代码中输入什么才能获得答案,显示在程序的股票订单部分中在一件事情表明,即使我已经输入了多个东西出售,所以我如何保存以前的交易显示在最后,即股票订单部分,我认为这是与柜台做的事情,但现在基本上需要知道如何保存以前输入的信息显示在最后。控制台应用程序VB,在所有页面上显示答案时都需要帮助

子的Main()

Dim start As String 
    Dim Sale As String 
    Dim Receipt As String 
    Dim endProgram As String 
    Dim StockOrder As New list(Of String) 



    Console.WriteLine("Welcome, Let's start today's sales") 
    Console.WriteLine() 
    Console.WriteLine("please type 'Yes' or 'No', Yes to Start and No to Stop") 
    start = Console.ReadLine() 

    Do 
     If (start = "Yes") Then 
      Console.WriteLine("What have you sold today? and for how much? and Please input Code on the side of the item") 
      Sale = Console.ReadLine 
      StockOrder.Add(Console.ReadLine) 


      Console.Clear() 
      Console.WriteLine() 
      Console.WriteLine("Customer Receipt") 
      Console.WriteLine() 
      Console.WriteLine(Sale) 
      Console.WriteLine() 
      Console.WriteLine("Dear customer thank you for shopping with us, we appreciated your custom. please note that we have a 14 day return policy in which you can return faulty or unused and unopened items, if any product is returned without any fault please know that a 25% handling fee may apply, for any repair you have a three month warranty, this warranty only includes fault with the item replaced and any additional faults that occur will not be our responsibility.") 
      Receipt = Console.ReadLine 

      Console.Clear() 
      Console.WriteLine() 
      Console.WriteLine() 
      Console.WriteLine("Would You Like to Continue?") 
      start = Console.ReadLine 

      If (start = "No") Then 
       Console.Clear() 
       Console.WriteLine("Stock Order and Sales Sheet") 
       Console.WriteLine() 


       Console.Write(String.Join(Environment.NewLine, StockOrder)) 

       For i = 0 To StockOrder.Count - 1 
        Console.WriteLine(StockOrder(i)) 
       Next 

      End If 

     ElseIf (start = "No") Then 

      Console.WriteLine("Since you don't want to use the program nothing else will be ordered in the stock order") 

      Console.WriteLine("Thank you for using this program") 
      endProgram = Console.ReadLine 
      End 
     End If 
    Loop 

End Sub 

前端模块

+0

你在问什么?此外,代码不会编译; 'StockOrder ='。 'StockOrder'的价值是什么? –

+0

什么是'销售'的数据类型 – CurseStacker

+0

股票订单没有价值,当我运行程序没有股票订单它运行良好我唯一的问题是将先前输入的信息保存到一个页面,所以如果我有多个销售,我只收到我输入的最近的东西的股票订单,我需要它为我添加的所有东西添加, –

回答

1

您可以使用股票的订单,可以存储多个字符串的字符串列表,还跟踪有多少字符串存储。

Dim stockList As New List(Of String) 'initialize empty string list 

stockList.Add(console.ReadLine) 'adds to the end of the list 

For i = 0 To stockList.Count - 1 'print out all entries in the list 
    console.WriteLine(stockList(i)) 
Next 
+0

这个半工作,而不是输入我写的东西输入 “System.Collections.Generic.List'1 [System.String]” 你知道为什么吗?谢谢,虽然略有改善:) –

+0

我认为它应该是我= 0 to stockList.Count - 1.因为列表的索引从0开始,所以没有任何位置stockList(stockList.Count) – obl

+0

此外,请确保你有“console.WriteLine(stockList(i))”而不是“console.WriteLine(stockList)”。我是列表中字符串的索引。 – obl

相关问题