码迷,mamicode.com
首页 > 其他好文 > 详细

VB 代码

时间:2015-06-24 20:44:45      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

用代码创建控件:例创建文本框 打开网站代码
    Dim T As Object Shell "explorer http://www.baidu.com"
    Static Num As Long  
    Set T = Me.Controls.Add("VB.textbox", "Text" & Num, Me) ‘第一个参数是要添加的控件,第二个是控件名 打开记事本
    T.Left = 122                 ‘设置 左边距离 Shell "notepad.exe", vbNormalFocus
    T.Top = 122 + Num * 600      ‘设置顶部距离  
    Num = Num + 1                ‘防止控件名重复  
    T.Visible = True             ‘设置控件可见  
   
MSGBOX 判断是否  
    If MsgBox("你真的想退出吗? ", vbYesNo, "退出提示 ") = vbYes Then  
        End  
    Else  
        Cancel = True  
    End If  
   
    A_Index.Adoo.CommandType = adCmdText  
    A_Index.Adoo.RecordSource = "Select * From Categories"  
    A_Index.Adoo.Refresh  
   
   
数据库连接代码  
    Dim RunSql, SqlStr As String  
    Dim Conn As New ADODB.Connection  
    Dim Rs As New ADODB.Recordset  
    Conn.OPEN "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\ERP.mdb;"  
    Rs.CursorLocation = adUseClient  
    RunSql = RunSqlText.Text  
    Rs.OPEN RunSql, Conn, 1, 3  
      
    SqlStr = LCase(Left(Trim(RunSql), 6))  
    If SqlStr = "select" Then  
        Set ViewBox.DataSource = Rs  
    Else  
    Rs.OPEN "Select * From Sale", Conn, 1, 3  
    Set ViewBox.DataSource = Rs  
      
    End If  
   
    Adodc1.Recordset.Close  
    Adodc1.CommandType = adCmdText  
    Adodc1.Recordset.ActiveConnection.Execute SQL  
    Adodc1.Refresh  
      
    Adodc1.Recordset.ActiveConnection.Execute "UPDATE sale SET 商品单价 = ‘13002‘"  
    Adodc1.Refresh  
      
    INSERT INTO Categories (产品分类编号,产品分类名称) VALUES (‘g‘,‘g‘)  

VB 代码

标签:

原文地址:http://www.cnblogs.com/vov5601/p/4598454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!