|
 |
|
ปรึกษาเรื่องโค้ด vb หน่อยครับ "ถ้าค่าปัจจุบันมีค่าเป็น 90 ถ้ากด start เเล้วปุ่ม 0 ต้องไม่ทำงาน" |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub btStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btStart.Click
Dim currenttime As DateTime
StartSecond = 0
checkKey = "0"
If warehouse_finsih = "90" Then
Me.btcall.Enabled = False
Exit Sub // ใส่ตรงนี้ครับ ถ้าไม่ใส่ loop การทำงานมันยังไปต่อ คำสั่งนี้ไว้ให้ออกจากการทำงานครับ
End If
If Me.lblItemCode.Text <> "" Then
If Me.cobOperator.Text = "" Then
MsgBox("Plase input Operator No.", vbCritical + vbOKOnly)
currenttime = Format(dtServerDateTime2, "yyyy-MM-dd H:mm:ss")
Me.cobOperator.Focus()
Me.btStart.Enabled = False
Me.btStop.Enabled = False
Me.btAdd.Enabled = False
Me.btRemove.Enabled = False
'//currenttime = System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")
Else
currenttime = Format(dtServerDateTime2, "yyyy-MM-dd H:mm:ss")
Call Start_Data_New()
Call Load_ExpectTime()
Timer1.Enabled = True
token_start = 0
Me.btStart.Enabled = False
Me.btStop.Enabled = True
Me.btAdd.Enabled = True
Me.btAdd.Focus()
Me.btRemove.Enabled = True
Me.btcall.Enabled = True
'//เพิ่มปุ่ม finish ทำงานหลังจากการที่กด start แล้ว
Me.btCloseOrder.Enabled = True
'//currenttime = System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")
End If
End If
End Sub
|
ประวัติการแก้ไข 2018-10-03 10:10:19
 |
 |
 |
 |
Date :
2018-10-03 10:09:53 |
By :
realizejoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรื่องตัวเลข 90 ของคุณยังแก้ไขไม่ได้หรอครับเห็นหลายๆกระทู้แล้ว
|
 |
 |
 |
 |
Date :
2018-10-03 10:11:08 |
By :
outhai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
btStart_Click มันแค่ สั่งให้ Timer1 มันทำงาน
แต่ตรงคำว่า อีกรอบนั้นไม่มี
ลองเขียนขั้นตอนการทำงานมาให้ดูหน่อยได้ไม๊ครับ
แล้วบอกด้วยว่าติดที่ขั้นตอนไหน
วิธีง่ายๆเวลาเจอปัญหา คือ เขียน ขั้นตอน อย่างละเอียด จากนั้นก็เช็คเลยว่ามันติดตรงขั้นตอนที่เท่าไหร่
จะช่วยได้เยอะมาก ครับ เวลาไปทำงานจริง และ ทำงานร่วมกับคนอื่น
เขาจะได้รู้รายละเอียดโดยไม่ต้องมานั่งอ่านโค้ดเรา ด้วยครับ
แค่เขามองขั้นตอน เขาก็จะรู้ได้ทันทีเลยว่าขั้นตอนไหนควรเขียนโค้ดยังไง
แทนที่เราจะแก้ทีละจุด แต่กลับมองไปทั้งโครงสร้าง ทำให้มีประสิทธิภาพในการแก้โค้ดมากกว่าครับ
คิดง่ายๆครับ
เราเอาโค้ดแค่
Code (VB.NET)
Private Sub btStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btStart.Click
Dim currenttime As DateTime
StartSecond = 0
checkKey = "0"
If warehouse_finsih = "90" Then
Me.btcall.Enabled = False
End If
If Me.lblItemCode.Text <> "" Then
If Me.cobOperator.Text = "" Then
MsgBox("Plase input Operator No.", vbCritical + vbOKOnly)
currenttime = Format(dtServerDateTime2, "yyyy-MM-dd H:mm:ss")
Me.cobOperator.Focus()
Me.btStart.Enabled = False
Me.btStop.Enabled = False
Me.btAdd.Enabled = False
Me.btRemove.Enabled = False
'//currenttime = System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")
Else
currenttime = Format(dtServerDateTime2, "yyyy-MM-dd H:mm:ss")
Call Start_Data_New()
Call Load_ExpectTime()
Timer1.Enabled = True
token_start = 0
Me.btStart.Enabled = False
Me.btStop.Enabled = True
Me.btAdd.Enabled = True
Me.btAdd.Focus()
Me.btRemove.Enabled = True
Me.btcall.Enabled = True
'//เพิ่มปุ่ม finish ทำงานหลังจากการที่กด start แล้ว
Me.btCloseOrder.Enabled = True
'//currenttime = System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")
End If
End If
End Sub
เดินไปถามรุ่นพี่ที่ทำงาน เราก็จะได้แก้แค่โค้ด ที่เราส่งไป
แต่ถ้าเรา เอา ขั้นตอนทำงานต่างๆไปด้วย
เขาจะเห็นภาพชัดขึ้นว่าก่อนที่จะมาเป็นโค้ดตัวปัญหา และ หลังจากโค้ดตัวปัญหา เราควรปรับตัวไหนบ้าง
เป็นการปรับทั้งโครงสร้าง ซึ่งจะดีกว่าปรับจุดเดียว และปรับ เรื่อยๆ หรือไม่ก็ปรับตลอดครับ
บางทีแก้ไปแก้มา ปรากฎว่า เจ้าโค้ดตัวปัญหา มันไม่จำเป็นต้องมีมาแต่แรก ก็เคยเป็น ครับ
|
 |
 |
 |
 |
Date :
2018-10-03 10:47:58 |
By :
วิ่งราว |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวแปร warehouse_finsih
เป็น String หรือ Int หรืออะไรครับ
ลอง MsgBox(warehouse_finsih) ดูครับว่าค่ามันเท่าไร
|
 |
 |
 |
 |
Date :
2018-10-03 11:53:49 |
By :
realizejoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามต่อได้เลยครับว่า
warehouse_finsih
method ไหนเป็นตัวกำหนดค่ามันอยู่ แล้วก็เช็คด้วยว่าตอนกด btStart_Click ค่า warehouse_finsih เป็นเท่าไหร่
|
 |
 |
 |
 |
Date :
2018-10-03 12:05:42 |
By :
วิ่งราว |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้ายังไม่ได้ ให้ไปเขียน Flowchart ก่อนนะครับ เขียนเป็นไหมครับ ถ้าไม่เป็นหาในเน็ตได้ครับ
เพราะอะไรรู้ไหมครับ เพราะเราจะได้เข้าใจขั้นตอน และลำดับการทำงาน
ผมเขียนโปรแกรมมาก็หลายปี ไม่เคยทิ้งเลย ไม่ว่าจะงานง่ายๆหรืออยากๆ
เข้าใจว่าต้องการคำตอบ แต่อันนี้คิดว่าทำเองได้เลย บ่ตอบ อย่าว่าข่อยเด้อ
และระวังจุดเล็กๆที่บังตาอยู่ หาอย่างไงก็ไม่เจอ พอทิ้งไว้สักพัก เออกูดักตัวเองเด้อ
|
 |
 |
 |
 |
Date :
2018-10-03 16:32:28 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|