 |
|
ทำไมใช้ Application.DoEvents() แล้วเวลาของ Timer ยังหยุดเดินอยู่ครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
void_Timer()
End Sub
Public Sub void_Timer()
Timer1.Start() '???????
End Sub
มีคำสั่งที่ทำให้ Timer1 เริ่มทำงานยังครับ
|
 |
 |
 |
 |
Date :
2016-10-03 17:59:10 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2016-10-04 12:06:21 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
WebBrowser1.Navigate(TextBox3.Text)
Thread.Sleep(1000)
WebBrowser1.Document.GetElementById("login_login_button").InvokeMember("Click")'มันขึ้นAdditional information: Object reference not set to an instance of an object. ตรงนี้เลยครับเหมือนมันไม่ยอมไป
Thread.Sleep(1000)
WebBrowser1.Document.GetElementById("nav_settings_link").InvokeMember("Click")
Thread.Sleep(1000)
WebBrowser1.Document.GetElementById("settings_utilities_link").InvokeMember("Click")
Thread.Sleep(1000)
WebBrowser1.Document.GetElementById("settings_utilitiesReboot_button").InvokeMember("Click")
Thread.Sleep(1000)
'WebBrowser1.Document.GetElementById("popup_apply_button").InvokeMember("Click") 'ปุ่มกดตกลง เพื่อ rebootting
|
 |
 |
 |
 |
Date :
2016-10-05 14:40:31 |
By :
Taksaporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โปรเจคของคุณ "น่าสนใจ" Arduino โชคไม่ดีมันใช้องค์ความรู้หลากหลายเกินไปสำหรับคุณ
--- สำหรับผมไม่มีปัญหา (จับจู๋ฉี่ยังยากยิ่งกว่า) +55555
ลองอ่านดูครับ "http://stackoverflow.com/questions/15954739/invokememberclick-in-webbrowser-control"
แนะให้อีกนิดหนึ่ง
Code (VB.NET)
Private Sub void_Port1On()
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(1) 'ส่งข้อมูลไปที่ pin 2 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add("Drive 2.0 of drive 1 status : ON")
End Sub
Private Sub void_Port2On()
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(2) 'ส่งข้อมูลไปที่ pin 3 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add("Drive 2.0 of drive 2 status : OFF")
End Sub
Private Sub void_Port3On()
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(3) 'ส่งข้อมูลไปที่ pin 4 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add("Drive 3.0 of drive 1 status : ON")
End Sub
Private Sub void_Port4On()
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(4) 'ส่งข้อมูลไปที่ pin 5 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add("Drive 3.0 of drive 2 status : ON")
End Sub
มันต้องเขียนแบบนี้
Code (VB.NET)
Private Sub void_PortXOnOff(ByVal X as Byte, ByVal Y As Byte)
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(X) 'ส่งข้อมูลไปที่ pin X + 1 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add(String.Format("Drive {0}.0 of drive {1} status : OFF", X, Y)
End Sub
แนะให้อีกนิดหนึ่ง การตั้งชื่อตัวแปร/Control ต่างฯ อทิเช่น
Form1
Form2
Form3
...
Label24
Label25
Label26
...
...
...
การตั้งชื่อตัวแปร/Control/etc.. แบบนี้
มันเหมาะสำหรับโปรแกรมมืออาชีพ/ขั้นสูง (ใช้ประโยชน์ได้จริง) แต่สำหรับคุณผมคิดว่ายังไม่เหมาะ (คุณยังมองไม่ออก)
--- สักวันหนึ่งคุณก็จะรู้ด้วยตัวของคุณเองว่า ประโยชน์ของมันมีมหาศาล
--- ยุคใหม่ นิยมตั้งชื่อตัวแปร/Control ให้สั้นที่สุด (ไม่จำเป็นต้องสื่อถึงอะไร) อทิเช่น
---- Dim a As String
---- var string a
---- Dim b As Integer
---- var int b
...
...
...
เป็นต้น หมดยุคตั้งชื่อให้สื่อความหมาย (แต่มีข้อแม้ว่า ต้องรู้จักวิธีใช้ประโยชน์จากมัน)
ปล. ถ้าคุณคุณพอมีความรู้ HTML/JavaScript/Jquery ผมคิดว่า งานของคุณจะง่ายกว่านี้
|
 |
 |
 |
 |
Date :
2016-10-06 20:52:47 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO 9 แก้ไขนิดหนึ่ง (เดี๋ยวคุณงง)
Code (VB.NET)
'
'Usage: Call PortXOnOff(1, 2, "ON")
'Usage: Call PortXOnOff(1, 2, "OFF")
'
Private Sub void_PortXOnOff(ByVal X as Byte, ByVal Y As Byte, ByVal Z As String)
SerialPort1.PortName = portComboBox.Text
SerialPort1.Open()
SerialPort1.Write(X) 'ส่งข้อมูลไปที่ pin X + 1 of Arduino open
SerialPort1.Close()
boxStatus.Items.Add(String.Format("Drive {0}.0 of drive {1} status : {2}", X, Y, Z)
End Sub
ปล. ผมยังไม่ได้พูดถึง Application.DoEvent() และ Theading เลยนะ
|
 |
 |
 |
 |
Date :
2016-10-06 20:56:30 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO9 - #NO10 ในหน้าจอ Login ของผม
ผมมักจะทำแบบนี้ (ไม่ให้ดักจับ ID/Name ของ Control ได้) ดังนี้
Code (VB.NET)
Dim a As String = Guid.NewGuid().ToString().Replace("-", String.Empty)
Dim b As String = Guid.NewGuid().ToString().Replace("-", String.Empty)
txtUserName.ID = a 'ถ้าเป็น Windows Application ก็ txtUserName.Name
txtPassword.ID = b 'ถ้าเป็น Windows Application ก็ txtPassword.Name
ไม่มีทางที่ JavaScript/Jquery จะจับ ID/Name ได้
ยกเว้นใน Application ของผมเท่านั้น +55555 (แสบสันต์ไหม?)
Code (VB.NET)
WebBrowser1.Document.GetElementById("nav_settings_link").InvokeMember("Click")
|
 |
 |
 |
 |
Date :
2016-10-06 21:15:37 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|