vb问题,解决一下
Private Sub Command1_Click()
If Text1.Text <> Text2.Text Then
MsgBox "两次输入不一致,请重新输入", vbOKOnly + vbExclamation, "信息提示"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Else
Adodc1.RecordSource = "select 用户名 from 用户登录 where 用户名='" & txtusername.Text & "'" '要求对象错误
Adodc1.Refresh
Adodc1.Recordset.Fields("密码") = Text1.Text '未设置对象变量
Adodc1.Recordset.Update
MsgBox "密码修改成功", vbOKOnly + vbExclamation
End If
End Sub
怎么改
追问:不对呀
答案:Private Sub Command1_Click() Dim SQL As String
Dim cnn As ADODB.Connection
Dim Rs1 As ADODB.Recordset
ConnectString = "FileDSN=数据库.dsn;UID=sa;PWD="
Set cnn = New ADODB.Connection
cnn.Open ConnectString
Set Rs1 = New ADODB.Recordset
SQL = "select 用户名 from 用户登录 where 用户名='" & txtusername.Text & "'"
rst.Open Trim(SQL),1,3
If Text1.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
else
While (Rs1.EOF = True)
If Trim(Text1.Text) <> Trim(Text2).Text) Then
MsgBox "两次输入密码不一样,请确认!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Exit Sub
Else
Rs1.AddNew
Rs1.Fields("密码") = Trim(Text1.Text)
Rs1.Update
Rs1.Close
Me.Hide
MsgBox "密码修改成功!", vbOKOnly + vbExclamation, "密码修改"
End If
Wend
End If
End Sub
你的窗体没有添加adodc控件吧,从部件中选择需要添加的控件如下图所示将Adodc控件增加进去,然后在窗体上画一个adodc控件,然后问题应该解决了:
个位: a = 1234 mod 10十位: b = (1234 - a) mod 100百位: c = (1234 - a - b) mod 1000百位: d = (1234 - a - b - c) mod 10000
vae.la
上一个:VB 的编程公式有哪些
下一个:VB和C语言 怎么学?