香奈儿cf是什么意思:VB的问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/02 20:50:32
今天看一段程序,有个地方不是很明白,希望大哥大姐们帮我解决一下,谢谢了~!
Private Sub cmdInquire_Click()
Dim txtSQL As String
Dim MsgText As String
Dim dd(4) As Boolean
Dim mrc As ADODB.Recordset
txtSQL = "select * from student_info where"
If Check1.Value Then
If Trim(txtSID.Text) = "" Then
smeg = "学号不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtSID.SetFocus
Exit Sub
Else
If Not IsNumeric(Trim(txtSID.Text)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtSID.SetFocus
End If
dd(0) = True

txtSQL = txtSQL & "student_id='" & Trim(txtSID.Text) & "'"
End If
End If
If Check2.Value Then
If Trim(txtName.Text) = "" Then
smeg = "姓名不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtName.SetFocus
Exit Sub
Else

dd(1) = True
If dd(0) Then
txtSQL = txtSQL & "and student_name='" & txtName.Text & "'"
Else
txtSQL = txtSQL & "student_name='" & txtName.Text & "'"
End If
End If
If Check3.Value Then
If Trim(txtClassno.Text) = "" Then
smeg = "班号不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtClassno.SetFocus
Exit Sub
Else
dd(2) = True
If dd(0) Or dd(1) Then
txtSQL = txtSQL & " and class_no='" & txtClassno.Text & "'"
Else
txtSQL = txtSQL & " class_no='" & txtClassno.Text & "'"
End If
End If
End If
If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
txtSQL = txtSQL & "order by student_ID"

就这段~!
不明白的有二:1:txtSQL = txtSQL & "and student_Name = '" & txtName.Text & "'" 这句话是什么意思?这句里的and student_Name = '这一句是什么意思?加一个’又是什么意思?
2:DD()表示什么?谢了!

首先txtSQL是一个文本框。 &是一个连接符
他的意思是把文本框中的内容和and student_Name ='还有txtName.Text 中的内容连起来在一起赋给文本框txtSQL。
连起来后是一个SQL查询语句。
and student_Name = ''意思是学生姓名是''中的。
加''是一个语法问题,用他把条件扩起来。

DD()是一个布尔型数组

有写东西我表达不清楚,请见凉

txtSQL = txtSQL & "and student_Name = '" & txtName.Text & "'" 这是一个SQL语句,如下:
select * from student_info where class_no="txtClassno.Text" and student_Name="txtName.Text"
意思是查询 班号=txtClassno.Text并且学生名=txtName.Text的学生的所有信息
具体txtSQL代表的SQL语句关键看你DD数组的值

DD()代表前面定义的布尔数组,
Dim dd(4) As Boolean

student的名字,是一个代表量.在此接收后面的字符串.

dd()
是一个数组

and student_Name = ' 应该是这样理解的and student_Name =
'" & txtName.Text & "'这句话的作用是引用一个变量,因为是在""内,所以引用变量必须加'"& &"'
用法如下:
a="hello"
b="a word",此时b的内容应该是字符串"a word"
如果换成b=" '"& a &"' word",此时b的内容应该是字符串"hello word"
-------------------------------------------------------------------
dd()我想不起来VB中数组可不可以用(),我记得应该是用[]做下标的

(1)首先'" & txtName.Text & "'这是一个分语句.它表示的是文本框txtName里的内容,把它的内容赋予student_Name 这个字符串变量.
(2)dd()是表示一个布尔型的数组.在该程序中这个数组有4个元素,每个元素只能有两种取值,True或者False.