This was the error msg im gettingenter image description here我有一個數據庫有一行「Total_Time」(時間)。 格式爲HH:MM:SS。我需要將代碼「Total_time」轉換爲分鐘。如何將總時間轉換爲分鐘
例如,如果Total_time = 01:30:00,答案應該是Total_minutes = 90, ,我想將total_minutes乘以「Other」(int變量)。
下面是我曾嘗試:
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
con = New System.Data.SqlClient.SqlConnection
Try
con.ConnectionString = "Data Source=Vicky-pc\sqlexpress;Initial Catalog=customer_details;Integrated Security=True;Pooling=False"
con.Open()
Dim cm As SqlClient.SqlCommand
cm = New SqlClient.SqlCommand("SELECT * FROM customer_details WHERE [email protected]", con)
cm.Parameters.AddWithValue("@id", TextBox5.Text)
dr = cm.ExecuteReader()
While dr.Read()
Dim tt As Double
tt = dr("Total_Time").ToString
Dim other As Double
other = dr("Other").ToString
Dim str() As String
Dim strmin As Double
str = Split(tt.ToString, ":")
strmin = (CDbl(str(1)) * 60 + CDbl(str(2)) + CDbl(str(3))/60).ToString
Dim total As Decimal
total = strmin + other
Label7.Text = total.ToString
End While
Catch ex As Exception
End Try
End Sub
但是當我點擊什麼也沒有發生label7沒有顯示任何值提前 感謝。
這是什麼問題? – Roope
我已經插入了這段代碼的一個按鈕,當我點擊什麼都沒有發生label7是不顯示任何值 –
你是不是意味着在年底Label7.Text = strmin –