Dim i As Integer
Dim a, b As Date
Dim ans As Double
Dim day As Integer
b = DateTimePicker1.Value
a = DateTimePicker2.Value
'คำนวณหาจำนวนวัน
day = DateDiff(DateInterval.Day, CDate(b), CDate(a))
day = day + 1
Dim SrtQuery As String
SrtQuery = "SELECT * FROM Depreciation "
Dim ws As New CheckSv
Ds = ws.ReadDb(SrtQuery, "ShowID")
For i = 0 To Ds.Tables("ShowID").Rows.Count - 1
Dim cost As Double = Ds.Tables("ShowID").Rows(i)("cost_price")
Dim scrap As Double = Ds.Tables("ShowID").Rows(i)("scrap_value")
Dim rate As Double = Ds.Tables("ShowID").Rows(i)("rate")
Dim depreciation As Double = Ds.Tables("ShowID").Rows(i)("depreciation")
Dim accumulate As Double = Ds.Tables("ShowID").Rows(i)("accumulate_depreciation")
ans = (((cost - scrap) * (rate / 100)) / 365) * day
TextBox2.Text = FormatNumber(ans, 2)
TextBox3.Text = FormatNumber(accumulate + ans, 2)
dim strUpdate as string 'เพิ่มเข้ามา dim intCol_A,intCol_B as integer
Dim SrtQuery As String
SrtQuery = "SELECT * FROM Depreciation "
Dim ws As New CheckSv
Ds = ws.ReadDb(SrtQuery, "ShowID")
For i = 0 To Ds.Tables("ShowID").Rows.Count - 1
Dim cost As Double = Ds.Tables("ShowID").Rows(i)("cost_price")
Dim scrap As Double = Ds.Tables("ShowID").Rows(i)("scrap_value")
Dim rate As Double = Ds.Tables("ShowID").Rows(i)("rate")
Dim depreciation As Double = Ds.Tables("ShowID").Rows(i)("depreciation")
Dim accumulate As Double = Ds.Tables("ShowID").Rows(i)("accumulate_depreciation")
ans = (((cost - scrap) * (rate / 100)) / 365) * day intCol_A = FormatNumber(ans, 2) intCol_B = FormatNumber(accumulate + ans, 2)
ตอนนี้ได้งี้ค่ะ
แต่มัน error ว่า Conversion from string " set depreciation ='" to type 'Double' is not valid.
Dim i As Integer
Dim a, b As Date
Dim ans As Double
Dim day As Integer
b = DateTimePicker1.Value
a = DateTimePicker2.Value
'คำนวณหาจำนวนวัน
day = DateDiff(DateInterval.Day, CDate(b), CDate(a))
day = day + 1
Dim StrAdd As String
Dim depre, acc As Double
Dim SrtQuery As String
SrtQuery = "SELECT * FROM Depreciation "
Dim ws As New CheckSv
Ds = ws.ReadDb(SrtQuery, "ShowID")
For i = 0 To Ds.Tables("ShowID").Rows.Count - 1
Dim cost As Double = Ds.Tables("ShowID").Rows(i)("cost_price")
Dim scrap As Double = Ds.Tables("ShowID").Rows(i)("scrap_value")
Dim rate As Double = Ds.Tables("ShowID").Rows(i)("rate")
Dim depreciation As Double = Ds.Tables("ShowID").Rows(i)("depreciation")
Dim accumulate As Double = Ds.Tables("ShowID").Rows(i)("accumulate_depreciation")
ans = (((cost - scrap) * (rate / 100)) / 365) * day
depre = FormatNumber(ans, 2)
acc = FormatNumber(accumulate + ans, 2)