2017-03-16 1 views
0

거기에 console.writeline (판매)을 입력하면 프로그램의 재고 주문 부분에 표시된 답변을 얻으려면이 코드에 무엇을 입력해야합니까? 한 가지는 내가 여러 물건을 판매용으로 입력 했더라도 마지막 거래를 저장하는 방법 (예 : 재고 주문 부분)입니다. 카운터와 관련이 있다고 생각하지만 기본적으로 저장 방법을 알아야합니다. 이전에 입력 된 정보가 끝에 표시됩니다.콘솔 응용 프로그램 VB, 모든 한 페이지에 답변을 표시 할 때 도움이 필요합니다

를 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

여러 문자열을 저장할 수있는 주식 주문에 대한 문자열 목록을 사용하여도 저장됩니다 얼마나 많은 문자열을 추적 할 수 있습니다.

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부터 시작되기 때문에 stockList (stockList.Count)의 위치에 아무 것도 없으므로 iStock = 0으로해야한다고 생각합니다. – obl

+0

또한 "console.WriteLine (stockList)"가 아닌 "console.WriteLine (stockList)"이 있어야합니다. i는 목록에있는 문자열의 색인입니다. – obl

관련 문제