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 –