Public Class Form_main Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click Dim
sqlcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VB.mdb;Persist Security Info=False" Dim con As New System.Data.OleDb.OleDbConnection(
sqlcon) con.Open() Try Dim
sql_select As String = "select * from table1 order by id asc" Dim cmd_id As New System.Data.OleDb.OleDbCommand(
sql_select,con) Dim drs As System.Data.OleDb.OleDbDataReader drs = cmd_id.ExecuteReader() drs.Read() Dim id As String id = drs.GetInt32(0) Message
Box.Show(id) Catch ex As Exception Message
Box.Show(ex.Message()) End Try Try Dim
sql1 As String = "insert into table1 values(1,'XC')" Dim cmd As New System.Data.OleDb.OleDbCommand(
sql1,con) cmd.ExecuteReader() Catch ex As Exception Message
Box.Show("插入数据失败,ID号不能重复") End Try Dim
sql As String = "select * from table1" Dim cmd2 As New System.Data.OleDb.OleDbCommand(
sql,con) Dim dr As System.Data.OleDb.OleDbDataReader dr = cmd2.ExecuteReader() Dim str As String While dr.Read() str += dr.GetInt32(0).ToString() str += " " str += dr.GetString(1) str += "\\n" End While Message
Box.Show(str) dr.Close() con.Close() End Sub Private Sub TreeView1_MouseDoubleClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.MouseEventArgs) Message
Box.Show("OK") End Sub Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button2.Click Picture
Box1.Refresh() Dim size As Drawing.Size size = Picture
Box1.Size() Picture
Box1.CreateGraphics().DrawLine(Pens.Blue,New Point(0,0),New Point(size.Width / 3 * 2,size.Height / 3 * 2)) End Sub Private Sub Picture
Box1_SizeChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Picture
Box1.SizeChanged Picture
Box1.Refresh() Dim size As Drawing.Size size = Picture
Box1.Size() Dim pen As New System.Drawing.Pen(System.Drawing.Color.Blue,1) pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash Picture
Box1.CreateGraphics().DrawLine(pen,size.Height / 3 * 2)) Picture
Box1.CreateGraphics.DrawLine(pen,10),New Point(100,10)) End Sub Private Sub Button3_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button3.Click Dim str As String str = Text
Box1.Text() Text
Box1.Text() = "aec" Message
Box.Show(str) End Sub Private Sub Form_main_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load TreeView1.Nodes.Add("PA") TreeView1.Nodes(0).Nodes.Add("P") TreeView1.Nodes(0).Nodes.Add("A") End Sub End Class
原文链接:https://www.f2er.com/vb/258936.html