2012-09-29 53 views
0

我有這個代碼的麻煩,我想爲我的課寫。程序本身工作,直到循環。我從來沒有做過一個循環,而且在她介紹它的那一天我還沒有上課,所以我就猜測它是如何完成的。如果任何人都可以發表評論,我應該如何解決這個問題會很好。這也是在VBA我需要幫助,試圖解決這個循環

Module Bits 

    Dim employeeName As String 
    Dim currentSalary As Decimal 
    Dim payIncrease As Single 
    Dim runReply As Char 
    Dim employeeSalary As Single 
    Dim numbersOfEmployees As Decimal 
    Dim projectedSalary As Decimal 
    Dim increasedSalary As Decimal 
    Dim y As Char 
    Dim n As Char 

    Sub Main() 

      Console.Out.WriteLine("Bits and Pieces Manufacturing Company") 
      Console.Out.WriteLine(DateString & "      By.Cristian Bouchez") 

     Do 

      Console.Out.Write(vbCrLf & "Enter your employee's name:     ") 
      employeeName = Console.In.ReadLine() 
      Console.Out.Write("Enter your employee's current weekly salary: $") 
      currentSalary = Console.In.ReadLine() 
      Console.Out.Write("Enter your employee's pay increase:   %") 
      payIncrease = Console.In.ReadLine() 

      payIncrease = payIncrease/100 
      employeeSalary = currentSalary * payIncrease 
      payIncrease = payIncrease * 100 
      employeeSalary = employeeSalary + currentSalary 

      numbersOfEmployees = numbersOfEmployees + 1 
      projectedSalary = projectedSalary + currentSalary 
      increasedSalary = increasedSalary + (employeeSalary - currentSalary) 

      Console.Out.WriteLine(vbCrLf & vbCrLf & employeeName & " will earn $" & employeeSalary & _ 
            " after a %" & payIncrease & " raise.") 

      Console.Out.WriteLine(vbCrLf & "Do you want to calaculate another employee's weekly pay?") 
      Console.Out.Write("Enter Y for yes and N for no: ") 
      runReply = Console.In.ReadLine() 

      Console.ReadKey() 

     Loop Until runReply = n 

     Console.Out.WriteLine(vbCrLf & "*******************************" & vbCrLf) 

    End Sub 

End Module 
+0

請添加更多細節。你能指望什麼?你遇到什麼問題? – Macmade

回答

2

1)設定N = 「N」
2)循環直到LCASE(runReply)= N

+0

它仍然繼續循環,即使有變化 – Cristian

+0

Nevermind。我沒有注意到你的報價 – Cristian

+0

好吧,我很高興你幫助解決了循環。 – Mate