以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  insert  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=55178)

--  作者:shanmao
--  发布时间:2014/8/12 12:07:00
--  insert

帮我看一下这一条代码对吗?值是从控件textbox中获取的。

cmd.CommandText = "Insert Into 人事 (用户名, 用户密码) Values("e.Form.Controls("zcusername").text","e.Form.Controls("zcpassword").text")"

[此贴子已经被作者于2014-8-12 12:07:34编辑过]

--  作者:有点甜
--  发布时间:2014/8/12 12:10:00
--  
cmd.CommandText = "Insert Into 人事 (用户名, 用户密码) Values(\'" & e.Form.Controls("zcusername").text & "\',\'" & e.Form.Controls("zcpassword").text & "\')"
--  作者:shanmao
--  发布时间:2014/8/12 14:08:00
--  

 下面的代码,setbounds和text可以通过集合的方式优化吗?

 Dim lbl As WinForm.Label
        Dim labels() As String = {"label1","label2","label3","label4"}
        Dim lab As String
        For Each lab In labels
            lbl = e.Form.CreateControl(lab,ControlTypeEnum.Label)
            lbl.BackColor = Color.Transparent
            e.Form.Controls("PictureBox").AddControl(lbl)
        Next
        e.Form.Controls("label1").SetBounds(62,27,54,19)
        e.Form.Controls("label2").SetBounds(62,73,54,19)
        e.Form.Controls("label3").SetBounds(160,27,79,19)
        e.Form.Controls("label4").SetBounds(160,73,79,19)
        e.Form.Controls("label1").Text = "a"
        e.Form.Controls("label2").Text = "b"
        e.Form.Controls("label3").Text = "c"
        e.Form.Controls("abel4").Text = "d"
       


--  作者:有点甜
--  发布时间:2014/8/12 14:35:00
--  
Dim lbl As WinForm.Label
Dim labels() As String = {"label1|62,27,54,19|a","label2|62,73,54,19|b","label3|160,27,79,19|c","label4|160,73,79,19|d"}
Dim lab As String
For Each lab In labels
    Dim str() As String = lab.Split("|")
    lbl = e.Form.CreateControl(str(0),ControlTypeEnum.Label)
    lbl.BackColor = Color.Transparent
    lbl.Text = str(2)
    Dim ary() As String = str(1).Split(",")
    lbl.SetBounds(ary(0), ary(1), ary(2), ary(3))
    e.Form.Controls("PictureBox").AddControl(lbl)
Next