กลับไปรายการกระดานข่าว ตอบกลับ โพสใหม่

show and hide your form in windows system

'''''code vs2008  
'' ลาก control ชื่อ NotifyIcon ลงในform ก่อนเขียนโค้ดครับ
Imports System.Windows.Forms.NotifyIcon
Public Class Form1

    Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles MyBase.Resize
        ' If minimize form that will show in system tray.
        If System.Windows.Forms.FormWindowState.Minimized = WindowState Then
            NotifyIcon1.ShowBalloonTip(5, "Running", "Running PT@Rmutsv Program", ToolTipIcon.Info)

            Me.Hide()
        End If
    End Sub

    Private Sub NotifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.Click

        If Me.Visible Then
            Me.Hide()
        Else
            Me.Show()
            Me.ShowInTaskbar = True
            Me.WindowState = FormWindowState.Normal
            Me.StartPosition = FormStartPosition.CenterScreen
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Write to register
        Dim regKey As Microsoft.Win32.RegistryKey
        'regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)

        'regKey.OpenRemoteBaseKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
        regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)

        regKey.SetValue("show and hide your form in windows system", "ที่อยู่ไฟล์ที่จะใช้แสดงเช่นC:\Documents and Settings\xxx\My Documents\Visual Studio 2008\Projects\")
        regKey.Close()
    End Sub
'''''' เขียนโค้คลบค่าregisยังไม่ผ่านครับ  ใช้โปรแกรม ccleaner ลบค่าตอน start up ของเครื่องไปก่อนครับ
''''''scan virus ทุกรุ่น ยอมให้ code run ได้หมดครับ  ลองรันสังเกตุผลลัพย์ดูครับ code vs2008
End Class
Good exam better than teaching
ช่วยเขียนเรื่อง MS Access OLEDB ทีสิ ^_^ ขี้เกียจอ่ะ มันยาว
ขั้นตอนการเขียนโปรแกรม VB ติดต่อกับฐานข้อมูล Access 2007

1.        สร้างฐานข้อมูลจาก Access 2007 เมื่อเรียบร้อยแล้ว ให้ทำการปิดโปรแกรม Access
2.        สร้างโปรแกรมจาก VB ชื่ออะไรก็ได้ แล้วทำการบันทึกโปรแกรม
3.        นำฐานข้อมูลที่ได้สร้างไว้ในข้อ 1 ไปเก็บไว้ในโฟล์เดอร์ของโปรแกรม ในโฟล์เดอร์ bin\debug
4.        เปิดหน้าต่าง Code ของโปรแกรม พิมพ์คำสั่งลงไปในส่วนของ General/Declaration (บรรทัดบนสุดของคำสั่ง) ดังนี้

Imports System.Data.OleDb

5.        ทำการประกาศตัวแปรใน Public Class ของฟอร์มดังนี้
    Dim Cn As New OleDbConnection
    Dim Dr As OleDbDataReader
    Dim cm As OleDbCommand
    Dim DS As New DataSet
    Dim DA As OleDbDataAdapter

6.        ใน Private Sub Form_Load ให้เขียนคำสั่งเพื่อเชื่อมต่อกับฐานข้อมูล ดังนี้
Cn.ConnectionString = "Provider=Microsoft.ACE.OLeDB.12.0;
        Data Source=" & Application.StartupPath & "\db.accdb"
Cn.Open()

ในการเขียนคำสั่งภาษา SQL เพื่อทำงานร่วมกับฐานข้อมูลมี 2 ลักษณะคือ

รูปแบบการใช้คำสั่ง Insert,Update,Delete
cm = New OleDbCommand (“คำสั่ง SQL”, ตัวแปรที่ใช้ในการติดต่อกับฐานข้อมูล)
cm.ExecuteNonQuery()
เช่น
cm = New OleDbCommand("Insert into Product Values('" & TextBox1.Text & "','" &   
     TextBox2.Text & "','" & TextBox3.Text & "'," & TextBox4.Text & "’)", Cn)
cm.ExecuteNonQuery()

cm = New OleDbCommand("Delete From Product Where ProductID='" & TextBox1.Text
     & "'", Cn)
cm.ExecuteNonQuery()

cm = New OleDbCommand("Update Product Set ProductName='" & TextBox2.Text &  
     "',Price=" & TextBox4.Text & " Where ProductID='" & TextBox1.Text &
     "'", Cn)
cm.ExecuteNonQuery()
รูปแบบการใช้คำสั่ง Select
cm = New OleDbCommand (“คำสั่ง Select”, ตัวแปรที่ใช้ในการติดต่อกับฐานข้อมูล)
Dr = cm.ExecuteReader
เช่น
cm = New OleDbCommand("Select * From Product Where ProductID='" &
     TextBox1.Text & "'", Cn)
Dr = cm.ExecuteReader
Good exam better than teaching
ขอบคุนมากคับ
ขอบคุนมากคับ
^^






















<a href=http://www.adult-cms.com/ >cms porno</a>
Good exam better than teaching
ขอบคุณมาก ๆ
beer
NOTE: หัวข้อถูกปิด เจ้าของถูกแบนหรือถูกลบ
ในโพซีเยอร์ Private Sub Form1_Load
ผิดหมวดหรือ ผิดความหมายนะครับ
ผมขอย้ายกระทู้แทนแล้วกัน
คำสั่งในโพซีเยอร์นั้นมันอยู่ในส่วนของ Run As StartUp ครับ ซึ่งอาจจะเอาไปต่อเติมเป็นเปิดโปรแกรมนี้เมื่อเข้าสู่ระบบและอยู่ในโหมด hide + ใช้ NotifyIcon

You need to upgrade your Adobe Flash Player to watch this video.
Download it from Adobe.
กลับไปรายการกระดานข่าว