2017-03-16 4 views
0

私はconsole.writeline(売却)を置くと答えがプログラムの在庫注文部分に表示されるようにするために、このコードに何を入力しなければなりませんか?私は売り物のために複数のものを入力したとしても1つのことを示しているので、どのように私は最後に表示するために前の取引を保存する、すなわち株価の部分、私はそれがカウンターとは何かだと思うが、今は基本的に前に入力した情報が最後に表示されます。コンソールアプリケーションVB、すべての1ページに回答を表示するときに助けが必要

をSub 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

「Sale」のデータ型は何ですか – CurseStacker

+0

株価指数がなくてもプログラムを実行すると値段がなくなり、唯一の問題は以前に入力した情報を1ページに保存することになります。私が入力した最新のものの在庫注文のみを取得しました。私が追加したすべてのものに追加する必要があります。 –

答えて

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

私はそれがi = 0であるべきだと思います。stockListList.Count - 1.にリストのインデックスは0から始まるので、株式リスト(stockList.Count)の場所に何もないので – obl

+0

また、 「console.WriteLine(stockList)」ではなく「console.WriteLine(stockList(i))」があります。 iはリスト内の文字列のインデックスです。 – obl

関連する問題