2017-05-29 50 views
0

爲什麼我會一直輸入兩個輸入框而不是一個?我究竟做錯了什麼?我是如何通過函數傳遞價值的?如果是這樣,我該如何解決這個問題?視覺基本多輸入框我只需要1

Private Sub Calculate_Click(sender As Object, e As EventArgs) Handles Calculate.Click 

      'Dim ready_ship As Integer = GetInStock() 

      Dim display_spools As Integer = ReadyToShip() 
      Dim display_backOrders As Integer = BackOrdered() 


      lbl_rship.Text = display_spools.ToString() 
      lbl_backo.Text = display_backOrders.ToString() 





     End Sub 
     Function GetInStock() As Integer 


      Dim amount_Spools As String = Nothing 

      amount_Spools = InputBox(" Enter the number of spools currently in stock: ") 

      Return CInt(amount_Spools) 


     End Function 
     Function ReadyToShip() As Integer 
      Dim ready_ship As Integer = GetInStock() 
      Dim a As Integer 

      a = CInt(ready_ship) 

      Return a 
     End Function 
     Function BackOrdered() As Integer 
      Dim b As Integer = ReadyToShip() 
      Dim c As Integer 
      c = b - CInt(TextBox1.Text) 
      Return c 
     End Function 




    End Class 

回答

2

你Calculate_Click事件調用ReadyToShip()和延期交貨()功能,這都將GetInStock()函數,該函數顯示輸入框。所以它會顯示兩次。

0

使用屬性可以更好地服務此類,它們更容易管理,並且有助於避免此類方法重複。