修改时间:2024-07-12 浏览次数:221 类型:高考模拟
①密码是六位数字,前面两位为59;
②最后两位数字相同;
③能被12和38整除。
程序界面如图1所示,单击 “帮助找回密码”按钮(Command1)后,可能的密码显示在列表框List1中。
Private Sub Command1_click ( )
Dim x As Integer, s As Long, y As Integer, i As Integer
For i = 0 To 9999
S = 590000 + i
If Then
x= s mod 10
y = (s Mod 100) \ 10
If x = y Then
List1.AddItem Str(s)
End If
End If
Next i
End Sub
Private Sub Command1_Click()
Dim ch As String, s As String
Dim i As Integer, j As Integer
ch = Text1.Text
For i = 1 To
j = Asc(Mid(ch, i, 1))
If j > 96 And j < 123 Then
s = s + Chr(j - 32)
Else
s = s + Chr(j)
End If
Next
End Sub
假设共有1000个市民,市民的相关信息都存储在“information.accdb”的data表中,查询程序界面如图所示。工作人员在文本框Text1中输入卡号,单击“开始查询”按钮,如果找到,就在Label1中显示卡内市民姓名和卡内余额;否则显示“查无此人”。请按要求将下列程序补充完整。
Private Sub command1_click()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strSQL As String
Dim a,b as string ‘分别定义姓名、余额
Dim n as integer
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + App.Path + "\information.accdb" '打开到数据库的链接
conn.Open
strSQL ="select xh,xm from data where '卡号=&(Text1.Text) & '" '设置查询的SQL语句
Set rs.ActiveConnection = conn '设置rs的ActiveConnection属性,指定与其关联的数据库链接
rs.Open strSQL '打开记录集,将从表information中读取的结果保存到记录集rs中
Label1.Caption = ""
n=0
Do while not rs.EOF
①
a=rs.Fields("姓名")
b=rs.Fields("余额")
rs.movenext
loop
rs.Close
conn.close
set rs=nothing
set conn=nothing
②
if n=0 then Label1.caption="查无此人"
End Sub
试题篮