 |
|
Format ตัวเลข ต้องการ -1 หรือ +1 ในรูปแบบ format ต่างๆจะเขียน format ยังไงดีครับ |
|
 |
|
|
 |
 |
|
รบกวนด้วยนะครับ ตอนนี้ตันมากครับ ไม่รู้จะทำยังไงให้เลขที่ได้ เข้า รูปแบบที่ถูกต้อง ตอนนี้ตัดคำบวกเลขกันมั่วเลยครับ
|
 |
 |
 |
 |
Date :
2018-04-05 15:18:12 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งง กับความต้องการ
ลองแยกโดย split('.') ดูนะครับ
0.10 >> 0,10
10.1.2 >> 10,1,2
ทีนี้ก็แค่สร้างความเข้าใจว่า ตอนไหน เอา ตัวหน้า มา +- ตอนไหนเอาตัวหลังมา +-
ปัญหาไม่น่าจะมาจากการตัดคำ แต่น่าจะมาจากการสร้างเงื่อนไขในการเอามา +- นี่แหละครับ
|
 |
 |
 |
 |
Date :
2018-04-05 15:51:26 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
การบวกลบเลข เกิดจากการ ลบข้อใน grid หรือ เพิ่มข้อโดยการแทรกครับ การที่ กำหนดเลขบวกลบ เพราะว่า เลขพวกนั้นคือเลขข้อครับ มันเป็นการผูกสูตร เช่น ถ้าสมมุติจะคิดยอดรวมของข้อ 12 แต่ต้องคำนวนของข้อ 10.1.2 + 0.8 ด้วย ปัญหาคือว่า สูตรไม่สามารถใช้ชื่ออ้างอิงได้เพราะ user จะ กรอกชื่อแบบไม่ตายตัว แต่จะใช้ข้อต่างๆในการอ้างอิงสูตรครับ(user กรอกข้อเอง) เช่น จากข้างบน คือข้อ 10 และข้อ 8
(0.จะเป็นการบอกข้อใหญ่กรณีข้อนั้นๆไม่มีข้อย่อย แต่อย่างข้อ 10 จะมีข้อย่อย) สมมุติผมลบข้อ 6 ทิ้งไป 1 ข้อ เลขที่ผมบอกมาดังกล่าวจะถูก ลบ1 เป็นเลข 9.1.2+0.7 หรือถ้า insert แทรกก่อนข้อ 8 ไป เลขก็จะขยับขึ้นแทนเป็น 11.1.2+0.9
ปัญหาของผมคือ ผมจะทำยังไงให้เลขที่ได้มาแบบต่างๆ เข้า format เพื่อ บวก ลบ ได้ตรง ครับ format มีอยู่ประมาณ 5แบบครับ
ตอนนี้ผมทำแต่แค่ format ที่เลขมาได้แบบนี้อย่างเดียวครับ แบบอื่นยังทำไม่ได้จริงๆครับ
Code (VB.NET)
For i As Integer = 0 To dtformula.Rows.Count - 1
TSM_FORMULA_OLD = dtformula.Rows(i).Item("TSM_FORMULA") 'TSM_FORMULA_OLD = 0.20 + 0.15
If TSM_FORMULA_OLD <> "" Then
Dim Checknum As String = TSM_FORMULA_OLD
'Dim regex As String = System.Text.RegularExpressions.Regex.Replace(TSM_FORMULA_OLD, "^\d+[.]\d{2}$", " ")
If Checknum.ToString.Contains("0.") And Checknum.ToString.Contains("+0.") Or Checknum.ToString.Contains("-0.") = True Then
Dim strnum1 As Integer = TSM_FORMULA_OLD.Substring(2, 2)
Dim strnum2 As Integer = TSM_FORMULA_OLD.Substring(7, 2)
Dim strsign1 As String = TSM_FORMULA_OLD.Substring(4, 1)
Dim Sumformula As String
Sumformula = "0." & Convert.ToInt32(strnum1) - 1 & strsign1 & "0." & Convert.ToInt32(strnum2) - 1
TSM_FORMULA_NEW = Sumformula
End If
End If
Next
|
ประวัติการแก้ไข 2018-04-06 10:51:07 2018-04-06 10:51:48
 |
 |
 |
 |
Date :
2018-04-06 10:43:01 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
     
|
 |
 |
 |
 |
Date :
2018-04-10 07:43:03 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมอ้างอิงจากข้อมูลจริงเลยนะครับ



จากรูป แถวแรกสุดคือข้อที่แสดงผล gridview แบบธรรมดาครับ และแถวที่ 3 คือ หัวข้อที่จะใช้ทำการ -1 เมื่อ delete ข้อใน grid หรือ เพิ่มขึ้นเมื่อ insert แทรกข้อใน grid ซึ่ง ในแถวที่ 3 ต้อง สัมพันธ์กับข้อในแถวแรกครับ ข้อที่ขึ้นด้วย 0.XX คือ ข้อที่ไม่มีข้อย่อยใดๆ ส่วนข้อที่เป็นแบบเช่น 10.X.X คือข้อที่มีข้อย่อยครับ เมื่อทำการลบข้อมูล ที่มีผลต่อการขยับข้อ ในแถวที่ 3 ต้องทำการขยับตามครับ เช่น จากข้อ 10.x.x+0.20 เมื่อลบข้อใดข้อหนึ่งทิ้งที่ทำให้บรรทัดขยับขึ้น 1 บรรทัด(สมมุติว่าลบข้อ5) ก็จะได้ผลคือ 9.x.x+0.19 ประมาณนี้ครับ ส่วน % 1F พวกนั้นไม่ได้นำมา - + ไรครับ
|
ประวัติการแก้ไข 2018-04-10 10:00:03 2018-04-10 10:00:47 2018-04-10 10:03:30 2018-04-10 10:05:05
 |
 |
 |
 |
Date :
2018-04-10 09:57:43 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 6 เขียนโดย : bankguszo เมื่อวันที่ 2018-04-10 09:57:43
รายละเอียดของการตอบ ::
พอดีเนื้อหาที่อธิบายไม่ได้อ้างอิงรูปที่นำมาซักเท่าไหร่
อยากถามครับ
7.2 เป็นตัวเลขตั้งต้น หรือผลลัพธ์ ครับ
แล้ว 8.2.1-8.2.2+8.2.3+8.2.4 คืออะไร
สรุปว่าผลของแถวนี้คืออะไร
7.2.1 เป็นตัวเลขตั้งต้น หรือผลลัพธ์ ครับ
แล้ว 8.2.1,1 คืออะไร
สรุปว่าผลของแถวนี้คืออะไร
7.2.2 เป็นตัวเลขตั้งต้น หรือผลลัพธ์ ครับ
แล้ว 8.2.1 คืออะไร
สรุปว่าผลของแถวนี้คืออะไร
อาจจะยากหน่อยเพราะว่าต้องอธิบายให้คนที่ไม่ได้ทำงานกับเรารู้เรื่อง แต่ก็ลองอธิบายมาดูครับ
ผมเชื่อว่าขอแค่เข้าใจรูปแบบ และหารูปแบบตายตัวได้ การเขียนโค้ดนั้นไม่ใช่เรื่องยากเลย
|
 |
 |
 |
 |
Date :
2018-04-10 12:43:32 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 8 เขียนโดย : bankguszo เมื่อวันที่ 2018-04-11 08:39:10
รายละเอียดของการตอบ ::
สงสัยผมคงถามผิด
7.2 และ 8.2.1-8.2.2+8.2.3+8.2.4 เกี่ยวข้องกันยังไง
7.2.1 และ 8.2.1,1 เกี่ยวข้องกันยังไง
7.2.2 และ 8.2.1 เกี่ยวข้องกันยังไง
ประมาณว่า จาก 7.2 เป็น 8.2.1-8.2.2+8.2.3+8.2.4 มีการ +- อะไรมาบ้าง
หรือตัวเลขทั้ง 2 ไม่เกี่ยวเนื่องกัน
และอีกอย่างคือ
ข้อย่อย มีขีดจำกัดรึป่าว
เช่น 7.2 มีข้อย่อยแค่ 7.2.1-7.2.5
ส่วน 8.2 มีข้อย่อย 8.2.1-8.2.9
ถ้าเรามีข้อจำกัด เราใช้เกณฑ์กำหนด หรือให้ User กำหนดได้เรื่อยๆ รึครับ
|
 |
 |
 |
 |
Date :
2018-04-11 12:40:30 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่คือโค๊ดที่ผมสามารถทำ format ได้แค่ 2 ชุดครับ คือแบบ 0.10+0.10+0.10 และแบบ 1+2+3+4 ผมทำได้แค่ 2 ชุดนี้ครับ ยังไม่สามารถทำ format แบบอื่นได้เนื่องจาก เลขมาหลายรูปแบบ จะกำหนดเงื่อนไขยังไง ใช้ regex กำหนดแบบเลขเพื่อเข้าเงื่อนไขก็ทำไม่ได้ครับ เลขจะหลุดเข้าเงื่อนไขอื่นที่เราไม่ต้องการ ผมไม่รู้จะกำหนดรูปแบบยังไงครับเพราะมันกำหนดไม่ได้มาก ในโค๊ดตอนนี้ผมใช้เงื่อนไขเดียวกันนะครับ เพราะกำหนดไปหลายแบบมันก็หลุดเข้าเงื่อนไขอีกอันอยู่ดี
Code (VB.NET)
If dtformula.Rows.Count > 0 Then
For i As Integer = 0 To dtformula.Rows.Count - 1
TSM_FORMULA_OLD = dtformula.Rows(i).Item("TSM_FORMULA")
If TSM_FORMULA_OLD <> "" Then
Dim Getnum As String = System.Text.RegularExpressions.Regex.Replace(TSM_FORMULA_OLD, "[+,-]", " ") '"\d+[+,-]
Dim Getsign As String = System.Text.RegularExpressions.Regex.Replace(TSM_FORMULA_OLD, "\d+", " ")
'If IsNumeric(Getnum) And Getsign.Contains("+") Or Getsign.Contains("-") = True Then
' Dim Getsearchstr1 As String = System.Text.RegularExpressions.Regex.Replace(TSM_FORMULA_OLD, "0.", "0.")
' If Getsearchstr1.Contains(Getsearchstr1) > 0 Then
' Dim pattern As String = "[+,-]"
' Dim input As String = TSM_FORMULA_OLD
' Dim result() As String = Regex.Split(input, pattern)
' For ctr As Integer = 0 To result.Length - 1
' Console.Write("'{0}'", result(ctr))
' If ctr < result.Length - 1 Then Console.Write("")
' Dim GetResultnumber1 As String
' Dim GetResultnumber2 As String
' Dim GetResultnumber3 As String
' Dim GetResultnumber4 As String
' Dim GetResultnumber5 As String
' Dim GetResultnumber6 As String
' If result.Length = 1 Then
' GetResultnumber1 = result(0)
' End If
' If result.Length = 2 Then
' GetResultnumber1 = result(0)
' GetResultnumber2 = result(1)
' End If
' If result.Length = 3 Then
' GetResultnumber1 = result(0)
' GetResultnumber2 = result(1)
' GetResultnumber3 = result(2)
' End If
' If result.Length = 4 Then
' GetResultnumber1 = result(0)
' GetResultnumber2 = result(1)
' GetResultnumber3 = result(2)
' GetResultnumber4 = result(3)
' End If
' If result.Length = 5 Then
' GetResultnumber1 = result(0)
' GetResultnumber2 = result(1)
' GetResultnumber3 = result(2)
' GetResultnumber4 = result(3)
' GetResultnumber5 = result(4)
' End If
' If result.Length = 6 Then
' GetResultnumber1 = result(0)
' GetResultnumber2 = result(1)
' GetResultnumber3 = result(2)
' GetResultnumber4 = result(3)
' GetResultnumber5 = result(4)
' GetResultnumber6 = result(5)
' End If
' If GetResultnumber1 <> "" Then
' GetResultnumber1 = Convert.ToInt32(GetResultnumber1) - 1
' End If
' If GetResultnumber2 <> "" Then
' GetResultnumber2 = Convert.ToInt32(GetResultnumber2) - 1
' End If
' If GetResultnumber3 <> "" Then
' GetResultnumber3 = Convert.ToInt32(GetResultnumber3) - 1
' End If
' If GetResultnumber4 <> "" Then
' GetResultnumber4 = Convert.ToInt32(GetResultnumber4) - 1
' End If
' If GetResultnumber5 <> "" Then
' GetResultnumber5 = Convert.ToInt32(GetResultnumber5) - 1
' End If
' If GetResultnumber6 <> "" Then
' GetResultnumber6 = Convert.ToInt32(GetResultnumber6) - 1
' End If
' Console.WriteLine()
' Dim patternsign As String = "\d+"
' Dim inputsign As String = TSM_FORMULA_OLD
' Dim resultsign() As String = Regex.Split(inputsign, patternsign)
' For ctrsign As Integer = 0 To resultsign.Length - 1
' Console.Write("'{0}'", resultsign(ctrsign))
' If ctrsign < resultsign.Length - 1 Then Console.Write("")
' Dim GetResultsign1 As String = ""
' Dim GetResultsign2 As String = ""
' Dim GetResultsign3 As String = ""
' Dim GetResultsign4 As String = ""
' Dim GetResultsign5 As String = ""
' Dim GetResultsign6 As String = ""
' If resultsign.Length = 2 Then
' GetResultsign1 = resultsign(1)
' End If
' If resultsign.Length = 3 Then
' GetResultsign1 = resultsign(1)
' GetResultsign2 = resultsign(2)
' End If
' If resultsign.Length = 4 Then
' GetResultsign1 = resultsign(1)
' GetResultsign2 = resultsign(2)
' GetResultsign3 = resultsign(3)
' End If
' If resultsign.Length = 5 Then
' GetResultsign5 = resultsign(0)
' GetResultsign1 = resultsign(1)
' GetResultsign2 = resultsign(2)
' GetResultsign3 = resultsign(3)
' End If
' If resultsign.Length = 6 Then
' GetResultsign5 = resultsign(0)
' GetResultsign1 = resultsign(1)
' GetResultsign2 = resultsign(2)
' GetResultsign3 = resultsign(3)
' GetResultsign4 = resultsign(4)
' End If
' Console.WriteLine()
' Dim Sumformula As String
' Sumformula = GetResultnumber1 & GetResultsign1 & GetResultnumber2 & GetResultsign2 & GetResultnumber3 & GetResultsign3 & GetResultnumber4 & GetResultsign4 & GetResultnumber5 & GetResultsign5 & GetResultnumber6
' TSM_FORMULA_NEW = Sumformula
' Next
' Next
' End If
'End If
If IsNumeric(Getnum) And Getsign.Contains("+") Or Getsign.Contains("-") = True Then
Dim pattern As String = "[+-]"
Dim input As String = TSM_FORMULA_OLD
Dim result() As String = Regex.Split(input, pattern)
For ctr As Integer = 0 To result.Length - 1
Console.Write("'{0}'", result(ctr))
If ctr < result.Length - 1 Then Console.Write("")
Dim GetResultnumber1 As String
Dim GetResultnumber2 As String
Dim GetResultnumber3 As String
Dim GetResultnumber4 As String
Dim GetResultnumber5 As String
Dim GetResultnumber6 As String
If result.Length = 1 Then
GetResultnumber1 = result(0)
End If
If result.Length = 2 Then
GetResultnumber1 = result(0)
GetResultnumber2 = result(1)
End If
If result.Length = 3 Then
GetResultnumber1 = result(0)
GetResultnumber2 = result(1)
GetResultnumber3 = result(2)
End If
If result.Length = 4 Then
GetResultnumber1 = result(0)
GetResultnumber2 = result(1)
GetResultnumber3 = result(2)
GetResultnumber4 = result(3)
End If
If result.Length = 5 Then
GetResultnumber1 = result(0)
GetResultnumber2 = result(1)
GetResultnumber3 = result(2)
GetResultnumber4 = result(3)
GetResultnumber5 = result(4)
End If
If result.Length = 6 Then
GetResultnumber1 = result(0)
GetResultnumber2 = result(1)
GetResultnumber3 = result(2)
GetResultnumber4 = result(3)
GetResultnumber5 = result(4)
GetResultnumber6 = result(5)
End If
If GetResultnumber1 <> "" Then
GetResultnumber1 = Convert.ToDouble(GetResultnumber1)
If GetResultnumber1.Length = "4" And GetResultnumber1.Contains("1") Then
If GetResultnumber1.Contains("0.1") = False Then
GetResultnumber1 = GetResultnumber1 - 0.01 & "0"
Else : GetResultnumber1 = GetResultnumber1 - 0.01
End If
Else : GetResultnumber1 = GetResultnumber1 - 0.01
End If
End If
If GetResultnumber2 <> "" Then
GetResultnumber2 = Convert.ToDouble(GetResultnumber2)
If GetResultnumber2.Length = "4" And GetResultnumber2.Contains("1") Then
If GetResultnumber2.Contains("0.1") = False Then
GetResultnumber2 = GetResultnumber2 - 0.01 & "0"
Else : GetResultnumber2 = GetResultnumber2 - 0.01
End If
Else : GetResultnumber2 = GetResultnumber2 - 0.01
End If
End If
If GetResultnumber3 <> "" Then
GetResultnumber3 = Convert.ToDouble(GetResultnumber3)
If GetResultnumber3.Length = "4" And GetResultnumber3.Contains("1") Then
If GetResultnumber3.Contains("0.1") = False Then
GetResultnumber3 = GetResultnumber3 - 0.01 & "0"
Else : GetResultnumber3 = GetResultnumber3 - 0.01
End If
Else : GetResultnumber3 = GetResultnumber3 - 0.01
End If
End If
If GetResultnumber4 <> "" Then
GetResultnumber4 = Convert.ToDouble(GetResultnumber4)
If GetResultnumber4.Length = "4" And GetResultnumber4.Contains("1") Then
If GetResultnumber4.Contains("0.1") = False Then
GetResultnumber4 = GetResultnumber4 - 0.01 & "0"
Else : GetResultnumber4 = GetResultnumber4 - 0.01
End If
Else : GetResultnumber4 = GetResultnumber4 - 0.01
End If
End If
If GetResultnumber5 <> "" Then
GetResultnumber5 = Convert.ToDouble(GetResultnumber5)
If GetResultnumber5.Length = "4" And GetResultnumber5.Contains("1") Then
If GetResultnumber5.Contains("0.1") = False Then
GetResultnumber5 = GetResultnumber5 - 0.01 & "0"
Else : GetResultnumber5 = GetResultnumber5 - 0.01
End If
Else : GetResultnumber5 = GetResultnumber5 - 0.01
End If
End If
If GetResultnumber6 <> "" Then
GetResultnumber6 = Convert.ToDouble(GetResultnumber6) - 0.01
If GetResultnumber6.Length = "4" And GetResultnumber6.Contains("1") Then
If GetResultnumber6.Contains("0.1") = False Then
GetResultnumber6 = GetResultnumber6 - 0.01 & "0"
Else : GetResultnumber6 = GetResultnumber6 - 0.01
End If
Else : GetResultnumber6 = GetResultnumber6 - 0.01
End If
End If
Console.WriteLine()
Dim patternsign As String = "\d+.\d+"
Dim inputsign As String = TSM_FORMULA_OLD
Dim resultsign() As String = Regex.Split(inputsign, patternsign)
For ctrsign As Integer = 0 To resultsign.Length - 1
Console.Write("'{0}'", resultsign(ctrsign))
If ctrsign < resultsign.Length - 1 Then Console.Write("")
Dim GetResultsign1 As String = ""
Dim GetResultsign2 As String = ""
Dim GetResultsign3 As String = ""
Dim GetResultsign4 As String = ""
Dim GetResultsign5 As String = ""
Dim GetResultsign6 As String = ""
If resultsign.Length = 2 Then
GetResultsign1 = resultsign(1)
End If
If resultsign.Length = 3 Then
GetResultsign1 = resultsign(1)
GetResultsign2 = resultsign(2)
End If
If resultsign.Length = 4 Then
GetResultsign1 = resultsign(1)
GetResultsign2 = resultsign(2)
GetResultsign3 = resultsign(3)
End If
If resultsign.Length = 5 Then
GetResultsign1 = resultsign(1)
GetResultsign2 = resultsign(2)
GetResultsign3 = resultsign(3)
GetResultsign4 = resultsign(4)
End If
If resultsign.Length = 6 Then
GetResultsign1 = resultsign(1)
GetResultsign2 = resultsign(2)
GetResultsign3 = resultsign(3)
GetResultsign4 = resultsign(4)
GetResultsign5 = resultsign(5)
End If
If resultsign.Length = 7 Then
GetResultsign1 = resultsign(1)
GetResultsign2 = resultsign(2)
GetResultsign3 = resultsign(3)
GetResultsign4 = resultsign(4)
GetResultsign5 = resultsign(5)
GetResultsign6 = resultsign(6)
End If
Console.WriteLine()
Dim Sumformula As String
Sumformula = GetResultnumber1 & GetResultsign1 & GetResultnumber2 & GetResultsign2 & GetResultnumber3 & GetResultsign3 & GetResultnumber4 & GetResultsign4 & GetResultnumber5 & GetResultsign5 & GetResultnumber6
TSM_FORMULA_NEW = Sumformula
Next
Next
End If
End If
Next
End If
|
ประวัติการแก้ไข 2018-04-11 14:40:49 2018-04-11 14:49:46
 |
 |
 |
 |
Date :
2018-04-11 14:38:45 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากรู้ว่า
7.2.1 -1 =?
7.2 -1 = ?
ตอนนี้พอจะเข้าใจหลักการแล้วครับ
แต่ยังติดที่เราจะใช้กฎอะไรเพื่อใช้ในการ +- แค่นั้นเอง
|
 |
 |
 |
 |
Date :
2018-04-11 22:46:13 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าจะเปลี่ยนจาก 7.2.1 เป็น 7.2.2 หรือ 7.3.1 ละครับ
จะ +1 ตรงไหน ครับ และ มีอะไรชี้บ่งเพิ่มเติมรึปล่าว
หรือไม่ ช่วยอธิบาย operator ต่อไปนี้หน่อยครับ
7.2.1 *** = 8.2.1
7.2.1 *** = 6.2.1
7.2.1 *** = 7.2.0
7.2.1 *** = 7.2
7.2.1 *** = 7.2.2
การเพิ่มลดของ *** แต่ละแถวคืออะไร ครับ
แล้วจะรู้ได้ยังไงว่า ต้อง operator ที่ ข้อหลัก ข้อย่อย เพราะ มีแค่ +1/-1 แค่นั้นครับ
|
 |
 |
 |
 |
Date :
2018-04-12 10:03:59 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
database ทำไว้ยังไงครับ
การเก็บข้อมูลอ้าง id parent มีผลช่วยในการกำหนด เลขลำดับข้อ
และถ้ามีการลบข้อใดออกไป คงต้องใช้ loop เปลี่ยนชื่อข้อเอง
โดยอาจจะใช้ event เรียกใช้ function แก้ไข เลขลำดับข้อใหม่
|
 |
 |
 |
 |
Date :
2018-04-12 10:38:15 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 14 เขียนโดย : lamaka.tor เมื่อวันที่ 2018-04-12 10:03:59
รายละเอียดของการตอบ ::
แล้วถ้าจะเปลี่ยนจาก 7.2.1 เป็น 7.2.2 หรือ 7.3.1 ละครับ
จะ +1 ตรงไหน ครับ และ มีอะไรชี้บ่งเพิ่มเติมรึปล่าว
หรือไม่ ช่วยอธิบาย operator ต่อไปนี้หน่อยครับ
7.2.1 *** = 8.2.1
7.2.1 *** = 6.2.1
7.2.1 *** = 7.2.0
7.2.1 *** = 7.2
7.2.1 *** = 7.2.2
การเพิ่มลดของ *** แต่ละแถวคืออะไร ครับ
แล้วจะรู้ได้ยังไงว่า ต้อง operator ที่ ข้อหลัก ข้อย่อย เพราะ มีแค่ +1/-1 แค่นั้นครับ
ผมไม่ค่อยเข้าใจคำถามครับ แต่จะตอบแบบรวมๆแล้วกันครับ คือการเพิ่มหรือลด เราไม่ได้สนใจว่าตัวสีแดงด้านหลังจะเป็นเลขอะไร เราสนใจว่า ตัวสีเขียวจะลดหรือเพิ่มได้ถูกต้องหรือไม่ อย่างที่ผมบอกไปตอนแรกครับ ให้มองเลยพวกนี้คือข้อๆหนึ่ง เมื่อข้อหลักสักข้อถูกลบ ข้อทั้งหมดที่ต่อจากข้อที่ถูกลบเท่านั้นถึงจะมีผล จะมีการเปลี่ยนแปลงขยับตัวเลขสีเขียว 7.2.1 *** = 8.2.1
format ผมไม่แน่ใจว่าเข้าใจแบบผมไหมนะครับ แต่นี้คือ format แบบต่างๆ
0.20 = format1 ขึ้นต้นด้วย 0. คือข้อที่ไม่มีข้อย่อยใดๆแบบ format2
7 = format2 คือข้อหลักที่มีข้อย่อย format2 จะเป็น header ของ format3
7.2 = format3 คือข้อย่อยของ format 2
7.2.1 = format3 คือข้อย่อยของ format 3
ถ้ามถามว่า -1 จะรู้ได้ยังไงว่า อันไหนข้อหลัก ข้อย่อย เมื่อ hearder ของข้อย่อยแบบ format2 ถูกลบหรือเพิ่ม format3ที่เป็นข้อย่อยก็จะถูกปรับให้เหมือน header
เงื่อนไขไม่ได้มีไรเลยครับ มันก็คือการ sort เลขข้อใหม่ เพียงแต่เราไม่ได้ทำในเฉพาะ column ที่เป็นหัวข้อหลักอย่างเดียว เรามาทำเพิ่มใน column ที่ผูกสูตรด้วย และข้อย่อยต่างๆ ให้มันปรับตามข้อ hearder
|
ประวัติการแก้ไข 2018-04-12 10:53:37
 |
 |
 |
 |
Date :
2018-04-12 10:50:17 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรง formula ให้อ้างอิง id แทน No. แทน ครับ
ย้า id ไม่ใช่ No
no สามารถ เปลี่ยนแปลง ได้ตามการคำนวณ กรณ๊อยาก repair ให้เลขมันเรียงลำดับกัน
แต่ id จะไม่เปลี่ยนแปลงตามการ คำนวณ เป็น auto increment เพื่อที่การคำนวณจะได้ถูกต้อง
การแสดงผล no คุณต้องคิวรี่ formula จาก id แล้ว เอา no มาแสดง
ปล. ผิดที่การออกแบบ database ครับ การอ้างอิงแบบนี้ ไม่ใช้ ชื่อ หรอกครับ เพราะมันต้องมาสั่งซ่อมแซม กรณีมีการเปลี่ยนแปลง
สูตรต้องอ้างอิง field ที่ไม่มีการเปลี่ยนแปลง
และการออกแบบการนำเข้าก็สำคัญ คุณจะแยก operator กับ object ออกจากกันได้ยังไง เพื่อนำมาแสดงผล
เป็นหัวข้อให้คิด ไปอีกระดับ แล้วครับ
|
ประวัติการแก้ไข 2018-04-12 13:08:14
 |
 |
 |
 |
Date :
2018-04-12 13:00:42 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประเด็นคือเราต้องชี้บ่งได้ว่า
7.2.1 *** = 8.2.1
7.2.1 *** = 6.2.1
7.2.1 *** = 7.2.0
7.2.1 *** = 7.2
7.2.1 *** = 7.2.2
ไม่งั้น เราจะรู้ได้ยังไง ว่า 7.2.1+1 = 8.2.1 หรือ 7.2.1+1 = 7.3.1 หรือ 7.2.1+1 = 7.2.2
และยังมีเงื่อนไขอีกมากมายที่ต้องทยอยทำความเข้าใจเพิ่มเติมอีกด้วยครับ
|
 |
 |
 |
 |
Date :
2018-04-12 15:07:19 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าแก้ไขอะไรไม่ได้ ผมว่า อย่ารับงานเลยครับ จบข่าว
ผมว่าประเด็นน่าจะอยู่ที่ ต้องทำการแก้ไข field formula ขนานไปกับการแก้ field no
เช่นถ้าแก้ no 2 เป็น 1 ก็ต้องค้นหาอัพเดท formula ที่อ้างอิง no2 ให้แก้เป็น 1 ไปพร้อมๆ กัน
|
 |
 |
 |
 |
Date :
2018-04-12 15:54:56 |
By :
NewbiePHP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (SQL)
update p, c
set
c.formular = replace( c.formula, concat('0.',p.no), concat('0.', p.no-1 )
, p.no=p.no-1
from tablename as p
inner join tablename as c
on c.formula like concat('%0.',p.no,'%')
where p.no>?
ประมาณนี้ ไม่ได้ทดสอบ เพราะไม่มี server ให้ทดสอบ
|
 |
 |
 |
 |
Date :
2018-04-12 17:53:11 |
By :
NewbiePHP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สรุปว่าแก้ได้ไม๊ครับ
|
 |
 |
 |
 |
Date :
2018-04-19 09:22:25 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้เลยครับ ตอนนี้ตันจริงๆครับ ลองหลายรูปแบบแล้วครับ
ผมจะติดตรงที่ถ้า format เลขมาแนว 7.1.1 แบบนี้มีจุดหลายจุด และ ถ้าเลขมาหลาย format ใน ข้อเดียว เช่น 0.11+7.1.1+0.11..... ETC
ผมไม่สามารถนำมาบวกลบกันได้ครับ
|
ประวัติการแก้ไข 2018-04-19 13:15:30
 |
 |
 |
 |
Date :
2018-04-19 13:12:26 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สงสัย ที่มาของข้อมูลเอามาจากไหน จากไฟล์ excel หรือเปล่า หรือเอามาจาก ตารางใน database
และจะนำไปเก็บไว้ไหน หรือ แค่ convert ออกมาแสดงหน้าเวป เฉยๆ
วิธีนะมี แต่ก็ต้องรู้รายละเอียดมากกว่านี้ ต้องรู้ที่มาที่ไป จะได้เลือกใช้ โค๊ดได้ถูกต้อง
เอาเป็นว่าลองคิดซะว่าจ้างคนทำงาน จะต้องอธิบายยังไงให้คนรับจ้างเขาเข้าใจ
ไม่ใช่อธิบายแบบ โปรแกรมเมอร์ ( ส่วนใหญ่จะพูดแล้วตัวเองเข้าใจอยู่คนเดียว พูดให้คนอื่นฟังไม่รู้เรื่อง 55555)
ถ้ามีคนเข้าใจ เมื่อเขาพร้อม ว่าง เดี๋ยวเขาเข้ามาช่วยเอง
|
 |
 |
 |
 |
Date :
2018-04-19 15:11:49 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก็ไม่รู้จะอธิบายยังไงครับ คือบอกได้แค่ว่า ข้อ hearder ถูกเลื่อน ข้อลูกๆจะ . กี่ร้อยจุดก็เปลี่ยนแค่เลขหน้าสุดครับ ยกตัวอย่างก็เหมือนการ sort เลขข้อใหม่ครับจะมีข้อย่อยกี่ข้อไม่รู้ละ แต่เปลี่ยนแค่เลขข้อข้างหน้าสุด แค่นั้นจริงๆ ข้อย่อยจะมีเท่าไหร่ มันไม่ได้เปลี่ยนครับ
อยากให้มองเลขพวกนี้ เป็นชุดๆของมันครับ + - อิสระ ไม่สนเครื่องหมาย 0.11(ชุด1)+7.1.1(ชุด2)-16(ชุด3) แต่ละชุด +-1 แยกกันอิสระเมื่อข้อตัวเองถูกเลื่อนครับ
|
 |
 |
 |
 |
Date :
2018-04-20 07:44:58 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บางสิ่งบางอย่างไม่ใช่ว่าจะทำได้ทุกอย่างในการเขียนโค้ด เท่านั้น มันจะต้องที่ข้อตกลงและกฏของมัน
รูปแบบการนำเข้าหรือป้อนเข้าก็เช่นกันครับ เราควรต้องกำหนดรูปแบบที่สามารถทำได้ และบอกผู้ใช้
หรือขอร้อง ว่าเราสามารถทำได้แค่นี้ ไม่ใช่ว่าจะป้อนมาอย่างไงก็ได้เดียวเรามาตัดเอาอย่างนี้มันไม่ได้ครับ
ระบบใหญ่ๆเขายังมีข้อตกลงกันเลยครับผม ลำพังแค่
"มันเป็นการผูกสูตร เช่น ถ้าสมมุติจะคิดยอดรวมของข้อ 12 แต่ต้องคำนวนของข้อ 10.1.2 + 0.8 ด้วย ปัญหาคือว่า สูตรไม่สามารถใช้ชื่ออ้างอิงได้เพราะ user จะ กรอกชื่อแบบไม่ตายตัว แต่จะใช้ข้อต่างๆในการอ้างอิงสูตรครับ(user กรอกข้อเอง) เช่น จากข้างบน คือข้อ 10 และข้อ 8
(0.จะเป็นการบอกข้อใหญ่กรณีข้อนั้นๆไม่มีข้อย่อย แต่อย่างข้อ 10 จะมีข้อย่อย) สมมุติผมลบข้อ 6 ทิ้งไป 1 ข้อ เลขที่ผมบอกมาดังกล่าวจะถูก ลบ1 เป็นเลข 9.1.2+0.7 หรือถ้า insert แทรกก่อนข้อ 8 ไป เลขก็จะขยับขึ้นแทนเป็น 11.1.2+0.9"
ตัวอย่างที่ให้มา
มีการแทรกแถวก่อนข้อ 10.1.2 + 0.8
แล้วต้องการให้เป็น 11.1.2 + 0.9
อันนี้ตกลงจะให้บวกทั้งสองค่า คือ 10 และ 0.8 ใช่หรือไม่
แล้วอีก
มีการลบแถวก่อนข้อ 10.1.2 + 0.8
แล้วต้องการให้เป็น 9.1.2 + 0.7 ใช่หรือไม่
ถ้าใช้ก็คือ คุณต้องการให้บวกลบแค่เลขหลักหน้า และ หลังเท่านั้น(อันนี้ทำได้โดยการตัดคำเขียน function split แล้ว return ค่ากลับ)
โดยที่คุณจะต้องรู้ค่าของ แถวบนละแถวล้างก่อนที่จะทำการแทรกหรือลบก่อนเท่านั้น
แต่อ่านไปอ่านมา มันมีหลากหลายรูปแบบเหลือเกิน
ตามที่ผมดูนะครับ มีอยู่ 2 Column ที่ค่ามันเป็นตัวเลขและต้องการให้มันเปลี่ยนแปลงค่าตามการแทรกหรือลบใช่ไม่ไหมครับ
ถ้าใช่ให้คุณทำทีละ column ก่อน column ข้อหลักก่อนก็ได้ และขอให้รูปแบบให้มันตายตัวก่อน
ไม่งั้นเขียนอย่างไงก็ไม่ได้คำตอบที่ถูกต้องการ
และยังมีงงอีกเล็กน้อย ว่า 0.11(ชุด1)+7.1.1(ชุด2)-16(ชุด3)
0.11+7.1.1>>อันนี้อยู่ใน column แรกหรือ column ที่ 3 งงหลาย
ถ้าที่ผมเขียนมาผิดหมดก็ขอโทษด้วยนะครับผม ทีแรกพยามทำความเข้าใจความต้องการพออ่านไปอ่านมางงหนักว่าเดิม 555
|
 |
 |
 |
 |
Date :
2018-04-20 08:44:05 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอจะเข้าใจผมไหมครับ  


|
 |
 |
 |
 |
Date :
2018-04-20 10:04:34 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเรามองกันแบบนี้นะครับ

1 2 3 คือ ข้อหลัก
ส่วน 1.1,1.1.1 ....... พวกนี้คือข้อย่อย
ตามที่ผมเข้าใจคือ
ถ้าเราลบ 1.2 ออก
ตัว 1.3 จะขึ้นมาแทนเป็น 1.2 และส่งผลให้ 1.3.1 และ 1.3.2 มาเป็น 1.2.1 และ 1.2.2 ด้วย
ถ้าเราลบ 2 ออก
ข้อ 3 และ ข้อย่อยต่างๆก็จะเลื่อนขึ้นมาทั้งหมด
ผมเข้าใจถูกไม๊ครับ
เอาแค่นี้ก่อนครับ ถ้าผมเข้าใจถูกค่อยต่ออีกทีหนึ่ง
|
 |
 |
 |
 |
Date :
2018-04-20 10:52:53 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเข้าใจว่า คงทำได้ในเรื่องขอหลักก้แสดงว่ารู้แล้วว่าจะเพิ่มหรือจะลบใช่ไหมครับ
อันนี้ c# นะครับ
Code (C#)
string v = "9.2.1-9.2.3+9.2.4+9.2.5,1F";
string[] split = v.Split(new Char[] { ' ', '+', '-', ',', '\t' });
foreach (string s in split)
{
if (s.Trim() != "")
Console.WriteLine(s);
}
Console.ReadKey();
คือเราแยกชุดตัวเลขก่อน ที่นี้จะเอาไปทำอะไรต่อค่อยว่ากันอีกที
พอได้หรือเปล่าครับ ผมแปลงมาจาก
https://msdn.microsoft.com/en-us/library/b873y76a(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-8
อีกที
|
 |
 |
 |
 |
Date :
2018-04-20 13:49:04 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
8.2.1-8.2.2+8.2.3+8.2.4 ถ้ามีการเปลี่ยนแปลง จะไม่เป็น 8.2.1-8.2.4 หรือ 9.2.1-9.2.4 รึครับ
|
 |
 |
 |
 |
Date :
2018-04-20 15:39:13 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมหมายถึงว่าเมื่อ user แก้รอบแรก
เช่นมีการเพิ่มข้อเข้ามา
เราจะได้ว่า
8.2.1-8.2.2+8.2.3+8.2.4 คือเดิมเรามี 8.2.1-8.2.2 อยู่แล้ว แต่ เพิ่มมาอีก 2 ข้อคือ 8.2.3 และ 8.2.4
พอมีการแก้ไข้อีกรอบ เราไม่รวบยอด เป็น
7.2.1-7.2.2 หรือ 9.2.1-9.2.2
แต่จะเป็น
7.2.1-7.2.2+7.2.3+7.2.4 หรือ 9.2.1-9.2.2+9.2.3+9.2.4
แบบนี้รึครับ
|
 |
 |
 |
 |
Date :
2018-04-21 09:17:53 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรื่อง concept ผมไม่ถามแล้วครับ ถามโค๊ดดีกว่า คือว่าผมจะเอาสัญลักษณะ มาใส่ array ยังไงครับ โดยผมต้องการแยก แบบ + - คือ loop เดียวกัน .(จุด) คืออีก loop หนึ่ง ตอนนี้ผมแยกเลขได้แล้วครับ ลบ1 บวก1 ตรงตำแหน่ง แต่ผมจะแยกเครื่องหายยังไงครับ โดยให้มันเก็บเป็น array แบบ ที่บอก ถ้าแยกได้ ผมก็สามารถเอามารวมคำได้ครับ อันนี้โค๊ดที่ผมทำ แต่ไม่ถูกนะครับ
Code (VB.NET)
Dim sentence As String = TSM_FORMULA_OLD 'สมมุติเลข 16.4.1+16+17
Dim digits() As String = Regex.Split(sentence, "\d+") 'แยก arrayได้ array(0) = "" , array(1) = "." , array(2) = "." , array(3) = "+" , array(4) = "+" , array(5) = ""
Dim GetResultSign1 As String
Dim GetResultSign2 As String
Dim GetResultSign3 As String
Dim GetResultSign4 As String
Dim GetResultSign5 As String
Dim Getcharacter As String
Dim Getcha() As String
Dim Getsumsign() As String
For GetChardigits As Integer = 0 To digits.Length - 1
If digits.Contains("+") Or digits.Contains("-") Then
Getcharacter = digits(GetChardigits)
If Getcharacter = "+" Or Getcharacter = "-" Then
Getcha(Getcharacter) = Getsumsign(Getcharacter)
End If
End If
Next
|
ประวัติการแก้ไข 2018-04-24 16:26:31 2018-04-24 16:28:34 2018-04-24 16:29:19
 |
 |
 |
 |
Date :
2018-04-24 16:25:36 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมแยกแต่ละกลุ่มไว้ให้ พร้อมมีเครื่องหมายด้านหน้าด้วย

Code (VB.NET)
Dim strRegex as String = "([+-]?[\d\.]{1,})"
Dim myRegex As New Regex(strRegex, RegexOptions.None)
Dim strTargetString As String = "8.2.1-8.2.2+8.2.3+8.2.4"
For Each myMatch As Match In myRegex.Matches(strTargetString)
If myMatch.Success Then
' Add your code here
End If
Next
พอจะต่อได้ไม๊ครับ
|
 |
 |
 |
 |
Date :
2018-04-24 17:11:38 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าผมต้องการ แค่ + - หรือ แค่จุด จะเขียน pattern ยังไงครับ
|
 |
 |
 |
 |
Date :
2018-04-25 08:47:50 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้จะเอาไปทำอะไร แต่ก็จัดให้ครับ

มีแค่ +-. ตามที่บอกเปะๆ
Code (VB.NET)
Dim strRegex as String = "([\+-\.])"
Dim myRegex As New Regex(strRegex, RegexOptions.None)
Dim strTargetString As String = "8.2.1-8.2.2+8.2.3+8.2.4"
For Each myMatch As Match In myRegex.Matches(strTargetString)
If myMatch.Success Then
' Add your code here
End If
Next
|
 |
 |
 |
 |
Date :
2018-04-25 09:19:42 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันได้ค่านี้มาครับ ตาม pattern ข้างบน

|
 |
 |
 |
 |
Date :
2018-04-25 10:03:01 |
By :
bankguszo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ย้ำที่โค้ดอีกรอบครับ
Code (VB.NET)
Dim strRegex as String = "([\+-\.])"
Dim myRegex As New Regex(strRegex, RegexOptions.None)
Dim strTargetString As String = "8.2.1-8.2.2+8.2.3+8.2.4"
For Each myMatch As Match In myRegex.Matches(strTargetString)
If myMatch.Success Then
' Add your code here
End If
Next
|
 |
 |
 |
 |
Date :
2018-04-25 10:57:20 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|