需要一些幫助完成這個程序,一切正常,並運行像我想要的,但我需要顯示一個輸入框,允許用戶輸入他們希望的發票日期service_date存儲然後這個日期將顯示在列表框中,其中包含所有其他項目。我知道我需要使用AddDays函數,但我不知道如何去做,而在線研究讓我知道其他100件事情並非如此。在vb.net使用AddDays功能
因此,這裏是我的代碼:
Dim Customer As String
Dim Phone As String
Dim Hours As Double
Dim Parts As Double
Dim due_date As String
Dim service_date As String
Private Sub cmdInputBox_Click()
Dim service_date = InputBox("Enter the date of service. (MM/DD?YYYY)")
MsgBox("That's your date, " & service_date.ToString)
Exit Sub
End Sub
Private Sub CustInfo_Click()
Customer = txtCustomer.Text
Phone = mtbPhone.Text
Double.TryParse(txtHours.Text, Hours)
Double.TryParse(txtParts.Text, Parts)
If Customer.Length < 0 Then
MessageBox.Show("Please enter customer information.")
End If
If Phone = "" Then
MessageBox.Show("Please enter phone number.")
End If
If Not Double.TryParse(txtHours.Text, Hours) Then
MessageBox.Show("Please enter labor hours.")
End If
If Not Double.TryParse(txtParts.Text, Parts) Then
MessageBox.Show("Please enter parts and supplies.")
End If
''Perform calculations
Dim Total_Cost As Double
Dim Labor_Cost As Double
Dim Parts_Cost As Double
Parts_Cost = (Parts * 0.5 * 2)
Labor_Cost = (Hours * 35)
Total_Cost = (Hours + Parts)
Customer = txtCustomer.Text
Phone = mtbPhone.Text
lstBill.Items.Clear()
lstBill.Items.Add("Customer: " & vbTab & Customer.ToUpper)
lstBill.Items.Add("Phone: " & vbTab & vbTab & Phone)
lstBill.Items.Add("Service Date: " & vbTab & due_date)
lstBill.Items.Add("Invoice Date: " & vbTab & service_date)
lstBill.Items.Add("Labor Cost: " & vbTab & FormatCurrency(Labor_Cost))
lstBill.Items.Add("Parts Cost: " & vbTab & FormatCurrency(Parts_Cost))
lstBill.Items.Add("Total Cost: " & vbTab & FormatCurrency(Total_Cost))
Exit Sub
End Sub
Private Sub btnBill_Click(sender As System.Object, e As System.EventArgs) Handles btnBill.Click
cmdInputBox_Click()
CustInfo_Click()
End Sub
爲什麼不使用的DateTimePicker? – SSS
因爲用戶必須輸入它。我想過把它放在輸入框中......會在輸入框中工作嗎?用戶在單擊表單上的按鈕時會收到提示。 – compucrazy