2017-03-16 79 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

相關問題