随笔分类 -  VB编程

摘要:'*********初始化数据显示界面*********************************** 'DataGridView1.RowHeadersWidth = 60; '设置左边空列的宽度 DataGridView1.RowHeadersVisible = False '去掉最左边的空列 DataGridView1.Columns.Clear() '清除集合 DataGridView1.Columns.Add("bjbh", "表计编号") '添加列名及列的显示名称 DataGridView 阅读全文
posted @ 2011-09-20 08:43 爱测试的猫咪 阅读(6114) 评论(1) 推荐(1) 编辑
摘要:数据库-1连接后,加入下面一句conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient '加入这句防止查询记录数为-1 阅读全文
posted @ 2011-09-20 08:39 爱测试的猫咪 阅读(540) 评论(0) 推荐(0) 编辑
摘要:'获取桌面路径 path = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) 阅读全文
posted @ 2011-08-23 11:23 爱测试的猫咪 阅读(3872) 评论(0) 推荐(1) 编辑
摘要:Imports SystemImports System.IO.PortsPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '获取计算机有效串口 Dim ports As String() = SerialPort.GetPortNames() '必须用命名空间,用SerialPort,获取计算机的有效串口 Dim port As String ... 阅读全文
posted @ 2011-08-19 14:23 爱测试的猫咪 阅读(14160) 评论(4) 推荐(4) 编辑
摘要:Imports SystemImports System.IO.PortsPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '获取计算机有效串口 Dim ports As String() = SerialPort.GetPortNames() '必须用命名空间,用SerialPort,获取计算机的有效串口 Dim port As String For Each port In port 阅读全文
posted @ 2011-08-09 16:38 爱测试的猫咪 阅读(35190) 评论(9) 推荐(4) 编辑
摘要:1、右键点击DataGridView,选择编辑列,如图2、为每个列设置排序方式,点击“sortMode”,选择排序方式,一般采用默认排序方式即可,即“automatic”,表示可以倒序,也可以正序 阅读全文
posted @ 2011-08-06 10:26 爱测试的猫咪 阅读(1374) 评论(0) 推荐(0) 编辑
摘要:1、在窗体设计器中,单击DataGridView控件(不要双击,将会打开窗体的代码页);2、在属性窗口中,打开AlternatingRowsDefaultCellStyle属性;3、在外观中,点击BackColor属性的下拉箭头,显示CellStyleBuilder对话框,选择一个与当前颜色不同的颜色(默认是白色),可以选择紫色等,然后点击确定按钮。4、可以设置选中某一单元格或一行的显示颜色,单击“selectionBackColour”的箭头,进行选择合适的颜色 阅读全文
posted @ 2011-08-06 10:21 爱测试的猫咪 阅读(3938) 评论(0) 推荐(0) 编辑
摘要:有两种方法:(1):你在查询的那句SQL代码时: string sql = "select userName as 姓名,userNum as 编号,userClass as 所属部门 from userInfo";(显示的时候就是中文了)。(2):界面操作,把DataGridView控件拖放在窗体中,就看到DataGridView控件的右上角有个小三角,单击小三角,出现了“DataGridView任务”,或是直接右键DataGridView控件,选择“编辑列”;在弹出的“编辑列窗口中”,点“添加”,要几列就添加几列,在左边的“选定的列”中选择一列,然后再右边的“未绑定列属 阅读全文
posted @ 2011-08-06 10:00 爱测试的猫咪 阅读(8747) 评论(1) 推荐(0) 编辑
摘要:利用DataTable本身本身的个合并方法。Dim conn As New SqlConnection Dim rs As New SqlDataAdapter Dim ds As New DataSet Private Function connect_db() As SqlConnection Dim constr As String constr = "Server=PC-201105311336\SQLEXPRESS;uid=sa;pwd=123456;database=jiaxiaoai" 'rs.Fill(dataset, "student&q 阅读全文
posted @ 2011-08-06 09:50 爱测试的猫咪 阅读(2028) 评论(0) 推荐(0) 编辑
摘要:Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim sql As String Dim dt As New DataTable Time2 = "11:14:00" '设置定时的时间,24小时制 ,应该放在出事加载程序中 Timer1.Interval = 1000 '设置计时器每秒钟运行一次 ,应该放在出事加载程序中 Timer1.Enabled = True '计时器开始运行 ,应该放 阅读全文
posted @ 2011-08-05 11:31 爱测试的猫咪 阅读(1742) 评论(0) 推荐(0) 编辑
摘要:1 关于 通过SqlDataAdapter 插入DataSet中的数据到数据库 有两种方法: 2 3 (1) 4 5 使用SqlCommandBuilder 6 7 SqlConnection conn=new SqlConnection(); 8 conn.ConnectionString=ConfigurationManager.ConnectionStrings["TestDBConnectionString"].ConnectionString; 9 conn.Open();10 SqlCommand cmd=new SqlCommand();11 cmd.Comm 阅读全文
posted @ 2011-08-04 14:12 爱测试的猫咪 阅读(916) 评论(0) 推荐(0) 编辑
摘要:View Code 1 Public Sub connect() 2 Dim pass As Boolean 3 pass = False 4 Dim conn As New SqlConnection 5 Dim rs As New SqlCommand 6 Dim dataread As SqlDataReader 7 Dim constr As String 8 'Dim i As Integer 9 Dim sql As String10 constr = "server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Dat 阅读全文
posted @ 2011-08-04 12:17 爱测试的猫咪 阅读(892) 评论(0) 推荐(1) 编辑
摘要:代码如下:View Code 1 Public Class 全部学生信息 2 3 Dim conn As New SqlConnection 4 Dim rs As New SqlDataAdapter 5 'Dim dt As New DataTable 6 Dim ds As New DataSet 7 8 Public Function connect_db() As SqlConnection 9 Dim constr As String 10 constr = "Server=PC-201105311336\SQLEXPRESS;uid=sa;pwd=123456; 阅读全文
posted @ 2011-08-04 11:32 爱测试的猫咪 阅读(2998) 评论(0) 推荐(0) 编辑
摘要:学生信息显示代码:View Code Public Class 显示学生信息 Dim rs As New ADODB.Recordset Dim conn As New ADODB.Connection Public Function connect_db() As ADODB.Connection 'Dim conn As New ADODB.Connection Dim constr As String constr = ("Driver={SQL Server};server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Da 阅读全文
posted @ 2011-08-02 15:29 爱测试的猫咪 阅读(6055) 评论(0) 推荐(0) 编辑
摘要:1 Public Sub connect() 2 Dim conn As New SqlClient.SqlConnection("driver={SQL Server};server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Database=jiaxiaoai") 3 Dim myDataSet As New DataSet 4 Dim sql As String 5 sql = "select * from student" 6 Dim rs As SqlClient.SqlDataAdapter 7 阅读全文
posted @ 2011-08-01 16:01 爱测试的猫咪 阅读(5550) 评论(0) 推荐(0) 编辑
摘要:1、整型转换成字符串 str(整型变量)2、字符串转化为整型 val(字符串变量) 阅读全文
posted @ 2011-08-01 15:15 爱测试的猫咪 阅读(1501) 评论(0) 推荐(0) 编辑
摘要:登陆框代码: 1 '登陆框 2 Public Class 登陆 3 4 Private Sub okbtn_Click(ByVal sender As System.Object, ByVal e As 5 6 System.EventArgs) Handles okbtn.Click 7 If (Trim(usertext.Text) = "" Or Trim(passwordtext.Text) = "") 8 9 Then10 MsgBox("用户名或密码不能为空", vbOKOnly, "提示") 阅读全文
posted @ 2011-08-01 15:11 爱测试的猫咪 阅读(7728) 评论(0) 推荐(0) 编辑
摘要:开始的时候定义ADODB.Connection类型,会提示一个错误,是因为没有添加adodb的索引,在项目上添加索引,进入索引界面后,在com项中找到adodb引用,点击确定就可添加成功 阅读全文
posted @ 2011-07-30 10:54 爱测试的猫咪 阅读(3486) 评论(0) 推荐(0) 编辑
摘要:1 Public Sub connect() 2 Dim pass As Boolean 3 pass = False 4 Dim conn As New ADODB.Connection 5 Dim rs As New ADODB.Recordset 6 Dim constr As String 7 Dim i As Integer 8 Dim sql As String 9 constr = "driver={SQL Server};server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Database=jiaxiaoai&quo 阅读全文
posted @ 2011-07-30 10:44 爱测试的猫咪 阅读(5160) 评论(0) 推荐(0) 编辑