标题:我是才学的,关于一串代码我看不懂!求助!
取消只看楼主
yutengxw
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-12-27
结帖率:100%
 问题点数:0 回复次数:3 
我是才学的,关于一串代码我看不懂!求助!
Dim a

Private Sub Cmd_Hide_Click()
     frm_YHGL.Hide
End Sub

Private Sub Command1_Click()
Call main
    Adodc1.RecordSource = "select * from Table_yhxx"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.MoveLast
    Text6.Text = Val(Adodc1.Recordset.Fields("ID")) + 1    Else
    Text6.Text = 1
    End If
  If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
  MsgBox "输入不完全!!", 48, "医院住院管理系统"
  Else
          If Text2.Text = Text3.Text Then
          Set adoRs = adoCon.Execute("insert into Table_yhxx values(" & Text6 & ",'" & Text1 & "','" & Text2 & "','" & Check1 & "','" & Check2 & "','" & Check3 & "','" & Check4 & "','" & Check5 & "','" & Check6 & "','" & Check7 & "','" & Check8 & "','" & Check9 & "','" & Check10 & "')")
          MsgBox "注册成功!!", 48, "医院住院管理系统"
          Text1.Text = ""
          Text2.Text = ""
          Text3.Text = ""
          frm_YHGL.Hide
          Else
          MsgBox "两次输入的密码不一致,请您确认后重新输入", 48, "医院住院管理系统"
          Text2.Text = ""
          Text3.Text = ""
          Text2.SetFocus
          End If
  End If
adoCon.Close
End Sub

Private Sub Command2_Click()
    a = MsgBox("您确认要删除该用户吗?", 17, "医院住院管理系统")
    If a = vbOK Then
    Adodc1.RecordSource = "select * from Table_yhxx where 用户名='" + Text4.Text + "'"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.Delete
    frm_YHGL.Hide
    Else
    MsgBox "没有该用户的信息,请您确认后重新输入", 32, "医院住院管理系统"
    Text4.SetFocus
    End If
    Else
    End If
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Command4_Click()
frm_RYXS.Show
frm_RYXS.Caption = "用户删除"
End Sub

Private Sub Form_Activate()
If Option1.Value = 1 Then
Frame2.Visible = True
Frame1.Visible = False
Command1.Visible = True
Command2.Visible = False
ElseIf Option2.Value = 1 Then
Frame1.Visible = True
Frame2.Visible = False
Command2.Visible = True
Command1.Visible = False
Else
End If
End Sub

Private Sub Label3_Click()

End Sub

Private Sub Option1_Click()
Frame2.Visible = True
Frame1.Visible = False
Command1.Visible = True
Command2.Visible = False
Text1.SetFocus
End Sub

Private Sub Option2_Click()
Frame1.Visible = True
Frame2.Visible = False
Command2.Visible = True
Command1.Visible = False
Text4.SetFocus
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text2.SetFocus
Else
End If
End Sub

Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text3.SetFocus
Else
End If
End Sub

Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
Call main
If KeyCode = 13 Then
    Adodc1.RecordSource = "select * from Table_yhxx"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.MoveLast
    Text6.Text = Val(Adodc1.Recordset.Fields("ID")) + 1    Else
    Text6.Text = 1
    End If
  If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
  MsgBox "输入不完全!!", 48, "医院住院管理系统"
  Else
          If Text2.Text = Text3.Text Then
          Set adoRs = adoCon.Execute("insert into Table_yhxx values(" & Text6 & ",'" & Text1 & "','" & Text2 & "','" & Check1 & "','" & Check2 & "','" & Check3 & "','" & Check4 & "','" & Check5 & "','" & Check6 & "','" & Check7 & "','" & Check8 & "','" & Check9 & "','" & Check10 & "')")          MsgBox "注册成功!!", 48, "医院住院管理系统"
          Text1.Text = ""
          Text2.Text = ""
          Text3.Text = ""
          frm_YHGL.Hide
          Else
          MsgBox "两次输入的密码不一致,请您确认后重新输入", 48, "医院住院管理系统"
          Text2.Text = ""
          Text3.Text = ""
          Text2.SetFocus
          End If
  End If
Else
End If
adoCon.Close
End Sub

Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    a = MsgBox("您确认要删除该用户吗?", 17, "医院住院管理系统")
    If a = vbOK Then
    Adodc1.RecordSource = "select * from Table_yhxx where 用户名='" + Text4.Text + "'"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.Delete
    frm_YHGL.Hide
    Else
    MsgBox "没有该用户的信息,请您确认后重新输入", 32, "医院住院管理系统"
    Text4.SetFocus
    End If
    Else
    End If
Else
End If
End Sub



我是才开始学习VB的菜鸟,不过会是一个很努力的临时菜鸟,所以刚开始提问求助的时候可能会把我的问题说得不清楚,请大家多多体谅,我会应大家要求再来完善我的问题的!
这段代码是一个关于注册用户的窗体的代码,这个窗体上有3个TextBox控件、3个Label控件、1个Adodc控件、1个Frame控件和2个CommandButton控件.这个窗体的样子在附件中!这段代码中的红色部分我怎么也看不懂,是怎么一回事!还有那个Text4、Text6是哪儿冒出来的呀,怎么就出来了个Text6呢!谢谢大家能够指点指点我!

123.jpg (10.87 KB)
搜索更多相关主题的帖子: 才学 Sub 代码 Hide 
2007-12-27 14:56
yutengxw
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-12-27
得分:0 
谢谢你,非常的感谢你!我明白一些了,不过我把这段代码:
insert into Table_yhxx values(" & Text6 & ",'" & Text1 & "','" & Text2 & "','" & Check1 & "','" & Check2 & "','" & Check3 & "','" & Check4 & "','" & Check5 & "','" & Check6 & "','" & Check7 & "','" & Check8 & "','" & Check9 & "','" & Check10 & "')

复制到了SQL的查询分析器中,我想看看效果,可是提示错误:

服务器: 消息 128,级别 15,状态 1,行 1
在此上下文中不允许使用 ' & Text6 & '。此处只允许使用常量、表达式或变量。不允许使用列名。
这又是为什么呢?
2007-12-27 16:22
yutengxw
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-12-27
得分:0 
那么这些
" & Text6 & ",'" & Text1 & "','" & Text2 & "','" & Check1 & "','" & Check2 & "','" & Check3 & "','" & Check4 & "','" & Check5 & "','" & Check6 & "','" & Check7 & "','" & Check8 & "','" & Check9 & "','" & Check10 & "'
这一大串的东西都是变量了?可以这样理解吗?
2007-12-27 16:28
yutengxw
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-12-27
得分:0 
谢谢你的帮忙了!谢谢!
2007-12-27 17:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-194635-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.346682 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved